Fix flow errors...

This commit is contained in:
yflory 2018-06-04 15:19:24 +02:00
parent b0311ccec1
commit b87e7c003b

15
rpc.js
View File

@ -896,13 +896,13 @@ var removeOwnedBlob = function (Env, blobId, unsafeKey, cb) {
Fs.unlink(blobPath, w(function (e) { Fs.unlink(blobPath, w(function (e) {
if (e) { if (e) {
w.abort(); w.abort();
return void cb(e); return void cb(e.code);
} }
})); }));
}).nThen(function () { }).nThen(function () {
// Delete the proof of ownership // Delete the proof of ownership
Fs.unlink(ownPath, function (e) { Fs.unlink(ownPath, function (e) {
cb(e); cb(e && e.code);
}); });
}); });
}; };
@ -1204,7 +1204,7 @@ var owned_upload_complete = function (Env, safeKey, id, cb) {
return void cb(); return void cb();
} else { } else {
// it failed in an unexpected way. log it // it failed in an unexpected way. log it
WARN(e, 'ownedUploadComplete'); WARN('ownedUploadComplete', e);
return void cb(e.code); return void cb(e.code);
} }
}); });
@ -1221,13 +1221,13 @@ var owned_upload_complete = function (Env, safeKey, id, cb) {
Mkdirp(filePath, w(function (e /*, path */) { Mkdirp(filePath, w(function (e /*, path */) {
if (e) { // does not throw error if the directory already existed if (e) { // does not throw error if the directory already existed
w.abort(); w.abort();
return void cb(e); return void cb(e.code);
} }
})); }));
Mkdirp(ownPath, w(function (e /*, path */) { Mkdirp(ownPath, w(function (e /*, path */) {
if (e) { // does not throw error if the directory already existed if (e) { // does not throw error if the directory already existed
w.abort(); w.abort();
return void cb(e); return void cb(e.code);
} }
})); }));
}).nThen(function (w) { }).nThen(function (w) {
@ -1254,12 +1254,11 @@ var owned_upload_complete = function (Env, safeKey, id, cb) {
// flow is dumb and I need to guard against this which will never happen // flow is dumb and I need to guard against this which will never happen
/*:: if (typeof(oldPath) === 'object') { throw new Error('should never happen'); } */ /*:: if (typeof(oldPath) === 'object') { throw new Error('should never happen'); } */
Fs.rename(oldPath /* XXX */, finalPath, w(function (e) { Fs.rename(oldPath, finalPath, w(function (e) {
if (e) { if (e) {
// Remove the ownership file // Remove the ownership file
// XXX not needed if we have a cleanup script?
Fs.unlink(finalOwnPath, function (e) { Fs.unlink(finalOwnPath, function (e) {
WARN(e, 'Removing ownership file ownedUploadComplete'); WARN('E_UNLINK_OWN_FILE', e);
}); });
w.abort(); w.abort();
return void cb(e.code); return void cb(e.code);