Merge branch 'soon' into staging

pull/1/head
ansuz 4 years ago
commit 20691b5817

@ -86,6 +86,8 @@ Upload.cancel = function (Env, safeKey, arg, cb) {
Upload.complete_owned = function (Env, safeKey, arg, cb) { Upload.complete_owned = function (Env, safeKey, arg, cb) {
Env.blobStore.closeBlobstage(safeKey); 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);
}; };

@ -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 ready = false;
var store; var store;
var pinStore; var pinStore;
@ -231,11 +236,11 @@ const computeIndexFromOffset = function (channelName, offset, cb) {
Env.Log.info('WORKER_OFFSET_UPDATE', { Env.Log.info('WORKER_OFFSET_UPDATE', {
channel: channelName, channel: channelName,
start: start, start: start,
startMB: start / 1024 / 1024, startMB: round(start / 1024 / 1024),
update: new_start, update: new_start,
updateMB: new_start / 1024 / 1024, updateMB: round(new_start / 1024 / 1024),
diff: diff, diff: diff,
diffMB: diff / 1024 / 1024, diffMB: round(diff / 1024 / 1024),
}); });
})); }));
}).nThen(function () { }).nThen(function () {
@ -269,7 +274,7 @@ const computeIndex = function (data, cb) {
Env.Log.verbose('WORKER_OFFSET_RECOVERY', { Env.Log.verbose('WORKER_OFFSET_RECOVERY', {
channel: channelName, channel: channelName,
start: start, start: start,
startMB: start / 1024 / 1024, startMB: round(start / 1024 / 1024),
}); });
} }
})); }));
@ -544,11 +549,13 @@ const evictInactive = function (data, cb) {
Eviction(Env, cb); Eviction(Env, cb);
}; };
var reportStatus = function (Env, label, safeKey, err, id) { var reportStatus = function (Env, label, safeKey, err, id, size) {
var data = { var data = {
safeKey: safeKey, safeKey: safeKey,
err: err && err.message || err, err: err && err.message || err,
id: id, id: id,
size: size,
sizeMB: round((size || 0) / 1024 / 1024),
}; };
var method = err? 'error': 'info'; var method = err? 'error': 'info';
Env.Log[method](label, data); Env.Log[method](label, data);
@ -559,6 +566,7 @@ const completeUpload = function (data, cb) {
var owned = data.owned; var owned = data.owned;
var safeKey = data.safeKey; var safeKey = data.safeKey;
var arg = data.arg; var arg = data.arg;
var size = data.size;
var method; var method;
var label; var label;
@ -571,7 +579,7 @@ const completeUpload = function (data, cb) {
} }
Env.blobStore[method](safeKey, arg, function (err, id) { Env.blobStore[method](safeKey, arg, function (err, id) {
reportStatus(Env, label, safeKey, err, id); reportStatus(Env, label, safeKey, err, id, size);
cb(err, id); cb(err, id);
}); });
}; };

@ -434,12 +434,13 @@ Workers.initialize = function (Env, config, _cb) {
}, cb); }, cb);
}; };
Env.completeUpload = function (safeKey, arg, owned, cb) { Env.completeUpload = function (safeKey, arg, owned, size, cb) {
sendCommand({ sendCommand({
command: "COMPLETE_UPLOAD", command: "COMPLETE_UPLOAD",
owned: owned, // Boolean owned: owned, // Boolean
safeKey: safeKey, // String (public key) safeKey: safeKey, // String (public key)
arg: arg, // String (file id) arg: arg, // String (file id)
size: size, // Number || undefined
}, cb); }, cb);
}; };

Loading…
Cancel
Save