Add mbcheck.

This commit is contained in:
Young Hahn
2011-05-19 14:42:17 -04:00
parent c31d820313
commit 528fdf2625
5 changed files with 197 additions and 0 deletions

View File

@@ -34,6 +34,17 @@ MBTiles.prototype.exists = function(table, callback) {
}
};
// DB integrity check.
MBTiles.prototype.integrity = function(callback) {
this.db.get('PRAGMA quick_check(1)', function(err, row) {
if (!(row && row.integrity_check && row.integrity_check === 'ok')) {
callback(new Error('Corrupted database.'));
} else {
callback(null, true);
}
});
};
// Setup schema, indices, views for a new mbtiles database.
// Sets the synchronous flag to OFF for (much) faster inserts.
// See http://www.sqlite3.org/pragma.html#pragma_synchronous