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

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

Loading…
Cancel
Save