fix(clouddrop): only upload, skip share-link generation entirely
This commit is contained in:
parent
c6c59ce868
commit
f955064524
@ -12,7 +12,6 @@ const CHUNK_SIZE = 16 * 1024 * 1024; // 16 MB — server's fixed chunk size
|
|||||||
const INIT_TIMEOUT = 60_000;
|
const INIT_TIMEOUT = 60_000;
|
||||||
const CHUNK_TIMEOUT = 30 * 60_000; // 30 min per chunk
|
const CHUNK_TIMEOUT = 30 * 60_000; // 30 min per chunk
|
||||||
const COMPLETE_TIMEOUT = 5 * 60_000;
|
const COMPLETE_TIMEOUT = 5 * 60_000;
|
||||||
const SHARE_TIMEOUT = 30_000;
|
|
||||||
const SIMPLE_UPLOAD_TIMEOUT = 30 * 60_000;
|
const SIMPLE_UPLOAD_TIMEOUT = 30 * 60_000;
|
||||||
|
|
||||||
// Cap concurrent TCP connections to clouddrop.cc at 50 to stay well under
|
// Cap concurrent TCP connections to clouddrop.cc at 50 to stay well under
|
||||||
@ -78,29 +77,10 @@ class ClouddropUploader {
|
|||||||
fileId = await this._uploadChunked(filePath, fileName, fileSize, progressCb, signal, throttle);
|
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 {
|
return {
|
||||||
download_url: shareUrl || `${BASE_URL}/share/${fileCode}`,
|
download_url: `${BASE_URL}/share/${fileId}`,
|
||||||
embed_url: null,
|
embed_url: null,
|
||||||
file_code: fileCode
|
file_code: fileId
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,23 +206,6 @@ class ClouddropUploader {
|
|||||||
return fileId;
|
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).
|
* Lightweight auth check — GET /api/cloud/files (list root, small response).
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user