archive blocks before overwriting them

pull/1/head
ansuz 3 years ago
parent b5c3468b41
commit 7bdabb5cbc

@ -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);
});
};

Loading…
Cancel
Save