call back with errors instead of throwing within the Storage module
This commit is contained in:
@@ -951,7 +951,9 @@ var trimChannel = function (env, channelName, hash, _cb) {
|
||||
});
|
||||
};
|
||||
|
||||
module.exports.create = function (conf, cb) {
|
||||
module.exports.create = function (conf, _cb) {
|
||||
var cb = Util.once(Util.mkAsync(_cb));
|
||||
|
||||
var env = {
|
||||
root: conf.filePath || './datastore',
|
||||
archiveRoot: conf.archivePath || './data/archive',
|
||||
@@ -984,18 +986,19 @@ module.exports.create = function (conf, cb) {
|
||||
// make sure the store's directory exists
|
||||
Fse.mkdirp(env.root, PERMISSIVE, w(function (err) {
|
||||
if (err && err.code !== 'EEXIST') {
|
||||
throw err; // XXX
|
||||
w.abort();
|
||||
return void cb(err);
|
||||
}
|
||||
}));
|
||||
// make sure the cold storage directory exists
|
||||
Fse.mkdirp(env.archiveRoot, PERMISSIVE, w(function (err) {
|
||||
if (err && err.code !== 'EEXIST') {
|
||||
throw err; // XXX
|
||||
w.abort();
|
||||
return void cb(err);
|
||||
}
|
||||
}));
|
||||
}).nThen(function () {
|
||||
// XXX leave a place for an error
|
||||
cb({
|
||||
cb(void 0, {
|
||||
// OLDER METHODS
|
||||
// write a new message to a log
|
||||
message: function (channelName, content, cb) {
|
||||
|
||||
Reference in New Issue
Block a user