add reloading of database and test
This commit is contained in:
@@ -71,7 +71,7 @@ MBTiles.prototype._open = function(uri) {
|
||||
|
||||
this.filename = uri.pathname;
|
||||
Step(function() {
|
||||
mbtiles._db = new sqlite3.cached.Database(mbtiles.filename, this);
|
||||
mbtiles._db = new sqlite3.Database(mbtiles.filename, this);
|
||||
}, function(err) {
|
||||
if (err) return error(err);
|
||||
mbtiles._setup(this);
|
||||
@@ -81,6 +81,11 @@ MBTiles.prototype._open = function(uri) {
|
||||
}, function(err, stat) {
|
||||
if (err) return error(err);
|
||||
mbtiles._stat = stat;
|
||||
fs.watchFile(mbtiles.filename, { interval: 1000 }, function(cur, prev) {
|
||||
if (cur.mtime != prev.mtime) {
|
||||
delete cache[uri.pathname];
|
||||
}
|
||||
});
|
||||
mbtiles.open = true;
|
||||
mbtiles.emit('open', null, mbtiles);
|
||||
});
|
||||
@@ -138,6 +143,10 @@ MBTiles.prototype._exists = function(table, callback) {
|
||||
}
|
||||
};
|
||||
|
||||
MBTiles.prototype._close = function() {
|
||||
fs.unwatchFile(this.filename);
|
||||
};
|
||||
|
||||
// DB integrity check.
|
||||
//
|
||||
// - @param {Function(err)} callback
|
||||
|
||||
Reference in New Issue
Block a user