check that the file is in write mode

This commit is contained in:
Konstantin Käfer
2011-07-18 14:21:50 +02:00
parent 5924f22cf3
commit a0c816c691

View File

@@ -565,6 +565,7 @@ MBTiles.prototype.putTile = function(z, x, y, data, callback) {
MBTiles.prototype.putGrid = function(z, x, y, data, callback) {
if (typeof callback !== 'function') throw new Error('Callback needed');
if (!this.open) return callback(new Error('MBTiles not yet loaded'));
if (!this._isWritable) return callback(new Error('MBTiles not in write mode'));
// Flip Y coordinate because MBTiles files are TMS.
y = (1 << z) - 1 - y;