From 28336b8500688abedfc0059b7b7c77bfc508af1d Mon Sep 17 00:00:00 2001 From: FTCHD <144691102+FTCHD@users.noreply.github.com> Date: Tue, 21 Oct 2025 15:31:38 +0200 Subject: [PATCH] back off Signed-off-by: FTCHD <144691102+FTCHD@users.noreply.github.com> --- lib/rclone/init.ts | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/lib/rclone/init.ts b/lib/rclone/init.ts index a454bc1..1c58e63 100644 --- a/lib/rclone/init.ts +++ b/lib/rclone/init.ts @@ -442,8 +442,38 @@ export async function provisionRclone() { console.log('[provisionRclone] appLocalDataDirPath created') } - await copyFile(rcloneBinaryPath, `${appLocalDataDirPath}${sep()}${binaryName}`) - console.log('[provisionRclone] copied rclone binary') + const targetBinaryPath = `${appLocalDataDirPath}${sep()}${binaryName}` + console.log('[provisionRclone] targetBinaryPath', targetBinaryPath) + + const maxCopyRetries = 3 + for (let attempt = 1; attempt <= maxCopyRetries; attempt++) { + try { + await copyFile(rcloneBinaryPath, targetBinaryPath) + console.log('[provisionRclone] copied rclone binary') + break + } catch (copyError) { + console.log( + `[provisionRclone] attempt ${attempt}/${maxCopyRetries} failed to copy:`, + copyError + ) + + if (attempt < maxCopyRetries) { + // Wait a bit before retrying + await new Promise((resolve) => setTimeout(resolve, attempt * 1000)) + } else { + console.error('[provisionRclone] all copy attempts failed', copyError) + Sentry.captureException(copyError, { + extra: { + rcloneBinaryPath, + targetBinaryPath, + }, + }) + throw new Error( + 'Failed to provision rclone, file is busy. Install cli manually or try again later.' + ) + } + } + } const hasInstalled = await isInternalRcloneInstalled()