ensure keys are strings before inserting into sqlite - closes #20

This commit is contained in:
Dane Springmeyer
2012-04-20 14:40:17 -07:00
parent 6b6efbbfdf
commit 3507ac4a07

View File

@@ -549,7 +549,11 @@ MBTiles.prototype.putTile = function(z, x, y, data, callback) {
// Tilelive may pass us a data.key. If not, generate an md5
// from the image buffer data.
var id = data.key || crypto.createHash('md5').update(data).digest('hex');
var id;
if (data.key)
id = String(data.key);
else
id = crypto.createHash('md5').update(data).digest('hex');
if (!this._tileCache[id]) {
// This corresponds to the images table.
this._tileCache[id] = data;