cache file access
This commit is contained in:
@@ -10,6 +10,9 @@ var _ = require('underscore'),
|
||||
sm = new (require('sphericalmercator')),
|
||||
sqlite3 = require('sqlite3');
|
||||
|
||||
var DirectoryIndex = require('./directoryindex');
|
||||
|
||||
|
||||
if (process.env.NODE_ENV === 'test') sqlite3.verbose();
|
||||
|
||||
function noop(err) {
|
||||
@@ -109,26 +112,13 @@ MBTiles.registerProtocols = function(tilelive) {
|
||||
|
||||
// Finds all mbtiles file in the filepath and returns their tilesource URI.
|
||||
MBTiles.list = function(filepath, callback) {
|
||||
filepath = path.resolve(filepath);
|
||||
fs.readdir(filepath, function(err, files) {
|
||||
if (err) return callback(err);
|
||||
for (var result = {}, i = 0; i < files.length; i++) {
|
||||
var name = files[i].match(/^([\w-]+)\.mbtiles$/);
|
||||
if (name) result[name[1]] = 'mbtiles://' + path.join(filepath, name[0]);
|
||||
}
|
||||
return callback(null, result);
|
||||
});
|
||||
DirectoryIndex.create(filepath).getList(callback);
|
||||
};
|
||||
|
||||
// Finds an mbtiles file with the given ID in the filepath and returns a
|
||||
// tilesource URI.
|
||||
MBTiles.findID = function(filepath, id, callback) {
|
||||
filepath = path.resolve(filepath);
|
||||
var file = path.join(filepath, id + '.mbtiles');
|
||||
fs.stat(file, function(err, stats) {
|
||||
if (err) return callback(err);
|
||||
else return callback(null, 'mbtiles://' + file);
|
||||
});
|
||||
DirectoryIndex.create(filepath).getID(id, callback);
|
||||
};
|
||||
|
||||
// Retrieve the schema of the current mbtiles database and inform the caller of
|
||||
|
||||
Reference in New Issue
Block a user