From cba69a7806994e8b9d2ae9615429a2c47245074c Mon Sep 17 00:00:00 2001 From: Administrator Date: Sat, 11 Apr 2026 07:17:45 +0200 Subject: [PATCH] fix(clouddrop): retry share-link during post-processing, never fail upload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Upload completes on server but file is still being processed, so share-link fails. Retry up to 6x with backoff; on final failure, use fileId-based fallback URL instead of throwing — prevents upload-manager from retrying the entire multi-GB upload. --- lib/clouddrop-upload.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/clouddrop-upload.js b/lib/clouddrop-upload.js index 6a31130..7bd9585 100644 --- a/lib/clouddrop-upload.js +++ b/lib/clouddrop-upload.js @@ -78,10 +78,22 @@ class ClouddropUploader { fileId = await this._uploadChunked(filePath, fileName, fileSize, progressCb, signal, throttle); } - // Create a share link for the uploaded file - const shareUrl = await this._createShareLink(fileId, signal); + // 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)); + } + } - // Extract slug from share URL (format: https://clouddrop.cc/share/SLUG) const slugMatch = String(shareUrl || '').match(/\/share\/([a-zA-Z0-9]+)/); const fileCode = slugMatch ? slugMatch[1] : fileId;