Revert "cache file access"

This reverts commit fde3538493.

Conflicts:

	lib/directoryindex.js
This commit is contained in:
Konstantin Käfer
2011-09-22 17:02:08 +02:00
parent 222414b187
commit 411c92c304
2 changed files with 15 additions and 71 deletions
+15 -5
View File
@@ -10,9 +10,6 @@ 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) {
@@ -112,13 +109,26 @@ MBTiles.registerProtocols = function(tilelive) {
// Finds all mbtiles file in the filepath and returns their tilesource URI.
MBTiles.list = function(filepath, callback) {
DirectoryIndex.create(filepath).getList(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);
});
};
// Finds an mbtiles file with the given ID in the filepath and returns a
// tilesource URI.
MBTiles.findID = function(filepath, id, callback) {
DirectoryIndex.create(filepath).getID(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);
});
};
// Retrieve the schema of the current mbtiles database and inform the caller of