Files above 16 MB use CloudDrop's mega-lease protocol when the server has it switched on: the server picks the MEGA account and upload address, the uploader encrypts the file with MEGA's scheme in worker threads and sends it straight to MEGA, then the server registers the finished file. Each file stays whole in one account. Throttling, progress and cancellation work as before; without the server feature, or with MHU_CLOUDDROP_LEASE=0, the existing upload path is used unchanged. A start far below this machine's earlier lease throughput is restarted on another MEGA server when CloudDrop uploads are not just sharing a busy line. New error messages have English translations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E7HXdgTtkBuSJPpiTRCGa8
This commit is contained in:
1 parent
8de07502db
commit
702376f80d
5 files changed
+694
No files matched your search
@@ -0,0 +1,27 @@
|
||||
const { parentPort } = require('node:worker_threads');
|
||||
const { performance } = require('node:perf_hooks');
|
||||
const { encryptChunk } = require('./clouddrop-lease-crypto');
|
||||
|
||||
function transferable(buffer) {
|
||||
if (buffer.byteOffset === 0 && buffer.buffer.byteLength === buffer.length) return buffer.buffer;
|
||||
return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.length);
|
||||
}
|
||||
|
||||
parentPort.on('message', (job) => {
|
||||
const started = performance.now();
|
||||
try {
|
||||
const { cipher, macs } = encryptChunk({
|
||||
aesKey: Buffer.from(job.aesKey),
|
||||
nonce: Buffer.from(job.nonce),
|
||||
offset: job.offset,
|
||||
data: Buffer.from(job.data, 0, job.length),
|
||||
segments: job.segments,
|
||||
});
|
||||
const cipherBuffer = transferable(cipher);
|
||||
const macBuffer = transferable(macs);
|
||||
parentPort.postMessage({ id: job.id, cipher: cipherBuffer, macs: macBuffer, plain: job.data, ms: performance.now() - started },
|
||||
[cipherBuffer, macBuffer, job.data]);
|
||||
} catch (error) {
|
||||
parentPort.postMessage({ id: job.id, error: error && error.message ? error.message : String(error), plain: job.data }, [job.data]);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user