mirror of
https://github.com/cryptpad/cryptpad.git
synced 2026-09-14 11:05:41 +05:00
Merge branch 'scalable' into 2025.9-test
This commit is contained in:
commit
1dc3b21fe8
@ -8,7 +8,8 @@ const Pinning = require("./pin-rpc");
|
||||
const nThen = require("nthen");
|
||||
const Core = require("./core");
|
||||
|
||||
Upload.status = function (Env, safeKey, filesize, _cb) { // FIXME FILES
|
||||
Upload.status = function (Env, safeKey, data, _cb) { // FIXME FILES
|
||||
const filesize = data.size;
|
||||
var cb = Util.once(Util.mkAsync(_cb));
|
||||
|
||||
// validate that the provided size is actually a positive number
|
||||
@ -74,12 +75,12 @@ Upload.status = function (Env, safeKey, filesize, _cb) { // FIXME FILES
|
||||
});
|
||||
};
|
||||
|
||||
Upload.upload = function (Env, safeKey, chunk, cb) {
|
||||
Env.blobStore.uploadWs(safeKey, chunk, cb);
|
||||
Upload.upload = function (Env, safeKey, data, cb) {
|
||||
Env.blobStore.uploadWs(safeKey, data?.chunk, cb);
|
||||
};
|
||||
|
||||
Upload.cancel = function (Env, safeKey, arg, cb) {
|
||||
Env.blobStore.cancel(safeKey, arg, cb);
|
||||
Env.blobStore.cancel(safeKey, arg?.size, cb);
|
||||
};
|
||||
|
||||
var completeUpload = function (owned) {
|
||||
|
||||
@ -91,17 +91,6 @@ var factory = function (Util, Rpc) {
|
||||
});
|
||||
};
|
||||
|
||||
// Update the limit value for all the users and return the limit for your publicKey
|
||||
exp.updatePinLimits = function (cb) {
|
||||
rpc.send('UPDATE_LIMITS', undefined, function (e, response) {
|
||||
if (e) { return void cb(e); }
|
||||
if (response && response.length && typeof(response[0]) === "number") {
|
||||
cb (void 0, response[0], response[1], response[2]);
|
||||
} else {
|
||||
cb('INVALID_RESPONSE');
|
||||
}
|
||||
});
|
||||
};
|
||||
// Get the storage limit associated with your publicKey
|
||||
exp.getLimit = function (cb) {
|
||||
rpc.send('GET_LIMIT', undefined, function (e, response) {
|
||||
@ -189,13 +178,13 @@ var factory = function (Util, Rpc) {
|
||||
});
|
||||
};
|
||||
|
||||
exp.uploadStatus = function (size, cb) {
|
||||
if (typeof(size) !== 'number') {
|
||||
exp.uploadStatus = function (data, cb) {
|
||||
if (typeof(data?.size) !== 'number') {
|
||||
return void setTimeout(function () {
|
||||
cb('INVALID_SIZE');
|
||||
});
|
||||
}
|
||||
rpc.send('UPLOAD_STATUS', size, function (e, res) {
|
||||
rpc.send('UPLOAD_STATUS', data, function (e, res) {
|
||||
if (e) { return void cb(e); }
|
||||
var pending = res[0];
|
||||
if (typeof(pending) !== 'boolean') {
|
||||
@ -205,8 +194,8 @@ var factory = function (Util, Rpc) {
|
||||
});
|
||||
};
|
||||
|
||||
exp.uploadCancel = function (size, cb) {
|
||||
rpc.send('UPLOAD_CANCEL', size, function (e) {
|
||||
exp.uploadCancel = function (data, cb) {
|
||||
rpc.send('UPLOAD_CANCEL', data, function (e) {
|
||||
if (e) { return void cb(e); }
|
||||
cb();
|
||||
});
|
||||
|
||||
@ -393,7 +393,10 @@ const factory = (Sortify, UserObject, ProxyManager,
|
||||
var s = getStore(data.teamId);
|
||||
if (!s) { return void cb({ error: 'ENOTFOUND' }); }
|
||||
if (!s.rpc) { return void cb({error: 'RPC_NOT_READY'}); }
|
||||
s.rpc.uploadStatus(data.size, function (err, res) {
|
||||
s.rpc.uploadStatus({
|
||||
id: data.id,
|
||||
size: data.size
|
||||
}, function (err, res) {
|
||||
if (err) { return void cb({error:err}); }
|
||||
cb(res);
|
||||
});
|
||||
@ -403,7 +406,10 @@ const factory = (Sortify, UserObject, ProxyManager,
|
||||
var s = getStore(data.teamId);
|
||||
if (!s) { return void cb({ error: 'ENOTFOUND' }); }
|
||||
if (!s.rpc) { return void cb({error: 'RPC_NOT_READY'}); }
|
||||
s.rpc.uploadCancel(data.size, function (err, res) {
|
||||
s.rpc.uploadCancel({
|
||||
id: data.id,
|
||||
size: data.size
|
||||
}, function (err, res) {
|
||||
if (err) { return void cb({error:err}); }
|
||||
cb(res);
|
||||
});
|
||||
@ -413,7 +419,10 @@ const factory = (Sortify, UserObject, ProxyManager,
|
||||
var s = getStore(data.teamId);
|
||||
if (!s) { return void cb({ error: 'ENOTFOUND' }); }
|
||||
if (!s.rpc) { return void cb({error: 'RPC_NOT_READY'}); }
|
||||
s.rpc.send.unauthenticated('UPLOAD', data.chunk, function (e, msg) {
|
||||
s.rpc.send.unauthenticated('UPLOAD', {
|
||||
chunk: data.chunk,
|
||||
id: data.id
|
||||
}, function (e, msg) {
|
||||
cb({
|
||||
error: e,
|
||||
msg: msg
|
||||
|
||||
@ -631,22 +631,22 @@ define([
|
||||
});
|
||||
};
|
||||
|
||||
common.uploadStatus = function (teamId, size, cb) {
|
||||
postMessage("UPLOAD_STATUS", {teamId: teamId, size: size}, function (obj) {
|
||||
common.uploadStatus = function (teamId, id, size, cb) {
|
||||
postMessage("UPLOAD_STATUS", {teamId, id, size}, function (obj) {
|
||||
if (obj && obj.error) { return void cb(obj.error); }
|
||||
cb(null, obj);
|
||||
});
|
||||
};
|
||||
|
||||
common.uploadCancel = function (teamId, size, cb) {
|
||||
postMessage("UPLOAD_CANCEL", {teamId: teamId, size: size}, function (obj) {
|
||||
common.uploadCancel = function (teamId, id, size, cb) {
|
||||
postMessage("UPLOAD_CANCEL", {teamId, id, size}, function (obj) {
|
||||
if (obj && obj.error) { return void cb(obj.error); }
|
||||
cb(null, obj);
|
||||
});
|
||||
};
|
||||
|
||||
common.uploadChunk = function (teamId, data, cb) {
|
||||
postMessage("UPLOAD_CHUNK", {teamId: teamId, chunk: data}, function (obj) {
|
||||
common.uploadChunk = function (teamId, id, data, cb) {
|
||||
postMessage("UPLOAD_CHUNK", {teamId, id, chunk: data}, function (obj) {
|
||||
if (obj && obj.error) { return void cb(obj.error); }
|
||||
cb(null, obj);
|
||||
});
|
||||
|
||||
@ -35,12 +35,13 @@ define([
|
||||
|
||||
var sendChunkWs = function (box, cb) {
|
||||
var enc = Util.encodeBase64(box);
|
||||
common.uploadChunk(teamId, enc, function (e, msg) {
|
||||
common.uploadChunk(teamId, id, enc, function (e, msg) {
|
||||
cb(e, msg);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
const prefix = id.slice(0,2);
|
||||
let uploadUrl = '/upload-blob';
|
||||
let keys, cookie;
|
||||
if (ApiConfig.fileHost) {
|
||||
@ -60,7 +61,7 @@ define([
|
||||
edPublic: keys.edPublic
|
||||
};
|
||||
|
||||
fetch(uploadUrl, {
|
||||
fetch(`${uploadUrl}/${prefix}/${id}`, {
|
||||
method: 'post',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
@ -131,6 +132,7 @@ define([
|
||||
};
|
||||
ServerCommand(keys, {
|
||||
command: 'UPLOAD_COOKIE',
|
||||
id: id
|
||||
}, (err, data) => {
|
||||
cookie = data?.cookie;
|
||||
if (err || !cookie) { return void onError(err || 'NOCOOKIE'); }
|
||||
@ -139,7 +141,7 @@ define([
|
||||
});
|
||||
};
|
||||
|
||||
common.uploadStatus(teamId, estimate, function (e, pending) {
|
||||
common.uploadStatus(teamId, id, estimate, function (e, pending) {
|
||||
if (e) {
|
||||
console.error(e);
|
||||
onError(e);
|
||||
@ -149,7 +151,7 @@ define([
|
||||
if (pending) {
|
||||
return void onPending(function () {
|
||||
// if the user wants to cancel the pending upload to execute that one
|
||||
common.uploadCancel(teamId, estimate, function (e) {
|
||||
common.uploadCancel(teamId, id, estimate, function (e) {
|
||||
if (e) {
|
||||
return void console.error(e);
|
||||
}
|
||||
|
||||
2
www/common/worker.bundle.min.js
vendored
2
www/common/worker.bundle.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user