cache remote files, quick ugly test experiment?

This commit is contained in:
Mark Nadal 2020-01-24 12:02:17 -08:00
parent fe3a25682a
commit faa776a8e5
2 changed files with 21 additions and 0 deletions

20
lib/rfsmix.js Normal file
View File

@ -0,0 +1,20 @@
module.exports = function(opt, store){
var rfs = require('./rfs')(opt);
var p = store.put;
var g = store.get;
store.put = function(file, data, cb){
rfs.put(file, data, function(err, ok){
if(err){ return cb(err) }
console.log("rfs3 cached", file);
p(file, data, cb);
});
}
store.get = function(file, cb){
rfs.get(file, function(err, data){
console.log("rfs3 hijacked", file);
if(data){ return cb(err, data) }
g(file, cb);
});
}
return store;
}

View File

@ -98,6 +98,7 @@ function Store(opt){
});
};
//store.list(function(){ return true });
require('./rfsmix')(opt, store); // ugly, but gotta move fast for now.
return store;
}