From 2f4c363e1c31b813b80179dd9387e533077392a3 Mon Sep 17 00:00:00 2001 From: Subhamoy Biswas Date: Sun, 20 Jul 2025 12:39:07 +0530 Subject: [PATCH] fix: failing to move downloaded file from temp to download folder in some linux distros --- src/App.tsx | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 8b67995..ab8f183 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -273,21 +273,12 @@ export default function App({ children }: { children: React.ReactNode }) { setErroredDownloadId(downloadId); } } else { - downloadStatusUpdater.mutate({ download_id: downloadId, download_status: 'completed' }, { - onSuccess: (data) => { - console.log("Download status updated successfully:", data); - queryClient.invalidateQueries({ queryKey: ['download-states'] }); - }, - onError: (error) => { - console.error("Failed to update download status:", error); - } - }) - if (await fs.exists(tempDownloadPath)) { downloadFilePath = await generateSafeFilePath(downloadFilePath); - await fs.rename(tempDownloadPath, downloadFilePath); + await fs.copyFile(tempDownloadPath, downloadFilePath); + await fs.remove(tempDownloadPath); } - + downloadFilePathUpdater.mutate({ download_id: downloadId, filepath: downloadFilePath }, { onSuccess: (data) => { console.log("Download filepath updated successfully:", data); @@ -297,6 +288,16 @@ export default function App({ children }: { children: React.ReactNode }) { console.error("Failed to update download filepath:", error); } }) + + downloadStatusUpdater.mutate({ download_id: downloadId, download_status: 'completed' }, { + onSuccess: (data) => { + console.log("Download status updated successfully:", data); + queryClient.invalidateQueries({ queryKey: ['download-states'] }); + }, + onError: (error) => { + console.error("Failed to update download status:", error); + } + }) } });