From d35b015c3fa9f5002b66fb8df35806123e1dae04 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 28 Apr 2020 17:12:03 -0400 Subject: [PATCH] log some info on successful file uploads --- lib/commands/upload.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/commands/upload.js b/lib/commands/upload.js index c64368949..7286caa93 100644 --- a/lib/commands/upload.js +++ b/lib/commands/upload.js @@ -75,8 +75,21 @@ Upload.upload = function (Env, safeKey, chunk, cb) { Env.blobStore.upload(safeKey, chunk, cb); }; +var reportStatus = function (Env, label, safeKey, err, id) { + var data = { + safeKey: safeKey, + err: err && err.message || err, + id: id, + }; + var method = err? 'error': 'info'; + Env.Log[method](label, data); +}; + Upload.complete = function (Env, safeKey, arg, cb) { - Env.blobStore.complete(safeKey, arg, cb); + Env.blobStore.complete(safeKey, arg, function (err, id) { + reportStatus(Env, 'UPLOAD_COMPLETE', safeKey, err, id); + cb(err, id); + }); }; Upload.cancel = function (Env, safeKey, arg, cb) { @@ -84,6 +97,9 @@ Upload.cancel = function (Env, safeKey, arg, cb) { }; Upload.complete_owned = function (Env, safeKey, arg, cb) { - Env.blobStore.completeOwned(safeKey, arg, cb); + Env.blobStore.completeOwned(safeKey, arg, function (err, id) { + reportStatus(Env, 'UPLOAD_COMPLETE_OWNED', safeKey, err, id); + cb(err, id); + }); };