diff --git a/lib/clouddrop-upload.js b/lib/clouddrop-upload.js index 7bd9585..fe1aafb 100644 --- a/lib/clouddrop-upload.js +++ b/lib/clouddrop-upload.js @@ -12,7 +12,6 @@ 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 @@ -78,29 +77,10 @@ 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: shareUrl || `${BASE_URL}/share/${fileCode}`, + download_url: `${BASE_URL}/share/${fileId}`, embed_url: null, - file_code: fileCode + file_code: fileId }; } @@ -226,23 +206,6 @@ 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). */