Run clearCaches synchronously to prevent _commit from erroring out when called prior to startWriting completing.

This commit is contained in:
Young Hahn
2012-04-30 13:06:46 -04:00
parent 84c5fba64f
commit ff5b8f7a9b

View File

@@ -398,6 +398,7 @@ MBTiles.prototype.startWriting = function(callback) {
if (!this.open) return callback(new Error('MBTiles not yet loaded'));
var mbtiles = this;
mbtiles._clearCaches();
Step(function() {
mbtiles._setup(this);
}, function(err) {
@@ -406,7 +407,6 @@ MBTiles.prototype.startWriting = function(callback) {
// See http://www.sqlite3.org/pragma.html#pragma_synchronous
if (!mbtiles._isWritable) {
mbtiles._isWritable = 1;
mbtiles._clearCaches();
mbtiles._db.run('PRAGMA synchronous=OFF', this);
} else {
mbtiles._isWritable++;