Skip to content

Commit

Permalink
Pass paths to node-mbtiles in uri object.
Browse files Browse the repository at this point in the history
  • Loading branch information
yhahn committed Sep 4, 2014
1 parent 2c18dc1 commit c6cceba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 7 additions & 2 deletions lib/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,20 @@ module.exports = function(Source, cachedir) {
.update(source._xml || source.data.id)
.digest('hex')
.substr(0,16);
var cachepath = path.join(cachedir, hash + '.mbtiles?batch=1');
var cachepath = path.join(cachedir, hash + '.mbtiles');

if (cache[cachepath]) {
source._mbtiles = cache[cachepath];
cache[cachepath]._cacheStats.hit++;
return callback(null, source);
}

new MBTiles(cachepath, function(err, mbtiles) {
// Pass filepath to node-mbtiles in uri object to avoid
// url.parse() upstream mishandling windows paths.
new MBTiles({
pathname: cachepath,
query: { batch: 1 }
}, function(err, mbtiles) {
if (err) return callback(verbose('MBTiles ' + cachepath, err));
source._mbtiles = mbtiles;
source._mbtiles.startWriting(function(err) {
Expand Down
4 changes: 3 additions & 1 deletion lib/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,9 @@ source.mbtilesExport = function(id) {
}

function loadt() {
new MBTiles(tmp, function(err, t) {
// Pass filepath to node-mbtiles in uri object to avoid
// url.parse() upstream mishandling windows paths.
new MBTiles({ pathname:tmp }, function(err, t) {
if (err) return prog.emit('error', err);
tsrc = t;
copy();
Expand Down

0 comments on commit c6cceba

Please sign in to comment.