diff --git a/lib/commands/upload.js b/lib/commands/upload.js index 6dc0aa911..346262716 100644 --- a/lib/commands/upload.js +++ b/lib/commands/upload.js @@ -86,6 +86,8 @@ Upload.cancel = function (Env, safeKey, arg, cb) { Upload.complete_owned = function (Env, safeKey, arg, cb) { Env.blobStore.closeBlobstage(safeKey); - Env.completeUpload(safeKey, arg, true, cb); + var user = Core.getSession(Env.Sessions, safeKey); + var size = user.pendingUploadSize; + Env.completeUpload(safeKey, arg, true, size, cb); }; diff --git a/lib/workers/db-worker.js b/lib/workers/db-worker.js index 7f45dfaa2..5750ff7ac 100644 --- a/lib/workers/db-worker.js +++ b/lib/workers/db-worker.js @@ -30,6 +30,11 @@ Logger.levels.forEach(function (level) { }; }); +var DETAIL = 1000; +var round = function (n) { + return Math.floor(n * DETAIL) / DETAIL; +}; + var ready = false; var store; var pinStore; @@ -231,11 +236,11 @@ const computeIndexFromOffset = function (channelName, offset, cb) { Env.Log.info('WORKER_OFFSET_UPDATE', { channel: channelName, start: start, - startMB: start / 1024 / 1024, + startMB: round(start / 1024 / 1024), update: new_start, - updateMB: new_start / 1024 / 1024, + updateMB: round(new_start / 1024 / 1024), diff: diff, - diffMB: diff / 1024 / 1024, + diffMB: round(diff / 1024 / 1024), }); })); }).nThen(function () { @@ -269,7 +274,7 @@ const computeIndex = function (data, cb) { Env.Log.verbose('WORKER_OFFSET_RECOVERY', { channel: channelName, start: start, - startMB: start / 1024 / 1024, + startMB: round(start / 1024 / 1024), }); } })); @@ -544,11 +549,13 @@ const evictInactive = function (data, cb) { Eviction(Env, cb); }; -var reportStatus = function (Env, label, safeKey, err, id) { +var reportStatus = function (Env, label, safeKey, err, id, size) { var data = { safeKey: safeKey, err: err && err.message || err, id: id, + size: size, + sizeMB: round((size || 0) / 1024 / 1024), }; var method = err? 'error': 'info'; Env.Log[method](label, data); @@ -559,6 +566,7 @@ const completeUpload = function (data, cb) { var owned = data.owned; var safeKey = data.safeKey; var arg = data.arg; + var size = data.size; var method; var label; @@ -571,7 +579,7 @@ const completeUpload = function (data, cb) { } Env.blobStore[method](safeKey, arg, function (err, id) { - reportStatus(Env, label, safeKey, err, id); + reportStatus(Env, label, safeKey, err, id, size); cb(err, id); }); }; diff --git a/lib/workers/index.js b/lib/workers/index.js index c422a9f54..25c18d947 100644 --- a/lib/workers/index.js +++ b/lib/workers/index.js @@ -434,12 +434,13 @@ Workers.initialize = function (Env, config, _cb) { }, cb); }; - Env.completeUpload = function (safeKey, arg, owned, cb) { + Env.completeUpload = function (safeKey, arg, owned, size, cb) { sendCommand({ command: "COMPLETE_UPLOAD", owned: owned, // Boolean safeKey: safeKey, // String (public key) arg: arg, // String (file id) + size: size, // Number || undefined }, cb); };