diff --git a/lib/storage/block.js b/lib/storage/block.js index d3e7a1869..1078f6d2e 100644 --- a/lib/storage/block.js +++ b/lib/storage/block.js @@ -72,9 +72,16 @@ Block.write = function (Env, publicKey, buffer, _cb) { w.abort(); 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 () { - // XXX BLOCK check whether this overwrites a block - // XXX archive the old one if so Fs.writeFile(path, buffer, { encoding: 'binary' }, cb); }); };