|
|
|
@ -2,6 +2,8 @@
|
|
|
|
|
/* Use Nacl for checking signatures of messages */
|
|
|
|
|
var Nacl = require("tweetnacl");
|
|
|
|
|
|
|
|
|
|
var Fs = require("fs");
|
|
|
|
|
|
|
|
|
|
var RPC = module.exports;
|
|
|
|
|
|
|
|
|
|
var Store = require("./storage/file");
|
|
|
|
@ -380,19 +382,17 @@ var getLimit = function (cb) {
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var createBlobStaging = function (cb) {
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var createBlobStore = function (cb) {
|
|
|
|
|
var safeMkdir = function (path, cb) {
|
|
|
|
|
Fs.mkdir(path, function (e) {
|
|
|
|
|
if (!e || e.code === 'EEXIST') { return void cb(); }
|
|
|
|
|
cb(e);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var upload = function (store, Sessions, publicKey, cb) {
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*::const ConfigType = require('./config.example.js');*/
|
|
|
|
|
RPC.create = function (config /*:typeof(ConfigType)*/, cb /*:(?Error, ?Function)=>void*/) {
|
|
|
|
|
// load pin-store...
|
|
|
|
@ -509,15 +509,29 @@ RPC.create = function (config /*:typeof(ConfigType)*/, cb /*:(?Error, ?Function)
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var keyOrDefaultString = function (key, def) {
|
|
|
|
|
return typeof(config[key]) === 'string'? config[key]: def;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var pinPath = keyOrDefaultString('pinPath', './pins');
|
|
|
|
|
var blobPath = keyOrDefaultString('blobPath', './blob');
|
|
|
|
|
var blobStagingPath = keyOrDefaultString('blobStagingPath', './blobstage');
|
|
|
|
|
|
|
|
|
|
Store.create({
|
|
|
|
|
filePath: './pins'
|
|
|
|
|
filePath: pinPath,
|
|
|
|
|
}, function (s) {
|
|
|
|
|
store = s;
|
|
|
|
|
cb(void 0, rpc);
|
|
|
|
|
|
|
|
|
|
// expire old sessions once per minute
|
|
|
|
|
setInterval(function () {
|
|
|
|
|
expireSessions(Sessions);
|
|
|
|
|
}, 60000);
|
|
|
|
|
safeMkdir(blobPath, function (e) {
|
|
|
|
|
if (e) { throw e; }
|
|
|
|
|
safeMkdir(blobStagingPath, function (e) {
|
|
|
|
|
if (e) { throw e; }
|
|
|
|
|
cb(void 0, rpc);
|
|
|
|
|
// expire old sessions once per minute
|
|
|
|
|
setInterval(function () {
|
|
|
|
|
expireSessions(Sessions);
|
|
|
|
|
}, 60000);
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|