|
|
@ -72,9 +72,16 @@ Block.write = function (Env, publicKey, buffer, _cb) {
|
|
|
|
w.abort();
|
|
|
|
w.abort();
|
|
|
|
cb(err);
|
|
|
|
cb(err);
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
|
|
|
|
}).nThen(function (w) {
|
|
|
|
|
|
|
|
Block.archive(Env, publicKey, w(function (/* err */) {
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
we proceed even if there are errors.
|
|
|
|
|
|
|
|
it might be ENOENT (there is no file to archive)
|
|
|
|
|
|
|
|
or EACCES (bad filesystem permissions for the existing archived block?)
|
|
|
|
|
|
|
|
or lots of other things, none of which justify preventing the write
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
}));
|
|
|
|
}).nThen(function () {
|
|
|
|
}).nThen(function () {
|
|
|
|
// XXX BLOCK check whether this overwrites a block
|
|
|
|
|
|
|
|
// XXX archive the old one if so
|
|
|
|
|
|
|
|
Fs.writeFile(path, buffer, { encoding: 'binary' }, cb);
|
|
|
|
Fs.writeFile(path, buffer, { encoding: 'binary' }, cb);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|