Compare commits
No commits in common. "215a10186ef7ce458dc48aa6c379b1d4c629d9c7" and "c6c59ce8685b3936a663fe3e707bb2bf8d6fd2c5" have entirely different histories.
215a10186e
...
c6c59ce868
@ -12,6 +12,7 @@ const CHUNK_SIZE = 16 * 1024 * 1024; // 16 MB — server's fixed chunk size
|
||||
const INIT_TIMEOUT = 60_000;
|
||||
const CHUNK_TIMEOUT = 30 * 60_000; // 30 min per chunk
|
||||
const COMPLETE_TIMEOUT = 5 * 60_000;
|
||||
const SHARE_TIMEOUT = 30_000;
|
||||
const SIMPLE_UPLOAD_TIMEOUT = 30 * 60_000;
|
||||
|
||||
// Cap concurrent TCP connections to clouddrop.cc at 50 to stay well under
|
||||
@ -77,10 +78,29 @@ class ClouddropUploader {
|
||||
fileId = await this._uploadChunked(filePath, fileName, fileSize, progressCb, signal, throttle);
|
||||
}
|
||||
|
||||
// Create a share link — retry a few times while server post-processes the file.
|
||||
// If share-link ultimately fails, DO NOT throw: upload itself succeeded and we
|
||||
// don't want upload-manager to retry the entire (possibly multi-GB) upload.
|
||||
let shareUrl = null;
|
||||
const shareAttempts = 6;
|
||||
for (let i = 0; i < shareAttempts; i++) {
|
||||
if (signal && signal.aborted) throw new Error('Aborted');
|
||||
try {
|
||||
shareUrl = await this._createShareLink(fileId, signal);
|
||||
if (shareUrl) break;
|
||||
} catch (err) {
|
||||
if (i === shareAttempts - 1) break;
|
||||
await new Promise(r => setTimeout(r, 3000 + i * 2000));
|
||||
}
|
||||
}
|
||||
|
||||
const slugMatch = String(shareUrl || '').match(/\/share\/([a-zA-Z0-9]+)/);
|
||||
const fileCode = slugMatch ? slugMatch[1] : fileId;
|
||||
|
||||
return {
|
||||
download_url: `${BASE_URL}/share/${fileId}`,
|
||||
download_url: shareUrl || `${BASE_URL}/share/${fileCode}`,
|
||||
embed_url: null,
|
||||
file_code: fileId
|
||||
file_code: fileCode
|
||||
};
|
||||
}
|
||||
|
||||
@ -206,6 +226,23 @@ class ClouddropUploader {
|
||||
return fileId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a permanent share link for the uploaded file.
|
||||
*/
|
||||
async _createShareLink(fileId, signal) {
|
||||
const res = await request(`${API_BASE}/share-link`, {
|
||||
method: 'POST',
|
||||
dispatcher: clouddropAgent,
|
||||
signal,
|
||||
headers: this._headers({ 'Content-Type': 'application/json' }),
|
||||
body: JSON.stringify({ fileId, expiry: 'never' }),
|
||||
headersTimeout: SHARE_TIMEOUT,
|
||||
bodyTimeout: SHARE_TIMEOUT
|
||||
});
|
||||
const payload = await this._parseJsonResponse(res);
|
||||
return payload.url || (payload.slug ? `${BASE_URL}/share/${payload.slug}` : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lightweight auth check — GET /api/cloud/files (list root, small response).
|
||||
*/
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "multi-hoster-uploader",
|
||||
"version": "2.7.4",
|
||||
"version": "2.7.3",
|
||||
"description": "Upload files to doodstream, voe, vidmoly, byse simultaneously",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user