Be less strict when reading metadata.

If the metadata table or the requested field is
missing return null and allow the caller handle it.
This commit is contained in:
Will White
2012-08-16 09:29:32 -04:00
parent a669f604fb
commit 342f582c21
+3 -1
View File
@@ -247,7 +247,9 @@ MBTiles.prototype._metadata = function(key, callback) {
this._db.get('SELECT value FROM metadata WHERE name = ?', this._db.get('SELECT value FROM metadata WHERE name = ?',
key, key,
function(err, row) { function(err, row) {
if (!row || (err && err.errno == 1)) return callback(new Error('Key does not exist')); // If the metadata table or the requested field is missing return
// null and allow the caller handle it.
if (!row || (err && err.errno == 1)) return callback(null, null);
else if (err) return callback(err); else if (err) return callback(err);
else return callback(null, row.value); else return callback(null, row.value);
}); });