From 9405b0dcfc4ef2b823897fb403f8a130815a8a73 Mon Sep 17 00:00:00 2001 From: Chubby Granny Chaser Date: Mon, 7 Oct 2024 22:29:48 +0100 Subject: [PATCH] fix: removing backup folder before uploading --- src/main/events/cloud-save/download-game-artifact.ts | 1 + src/main/events/cloud-save/upload-save-game.ts | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/main/events/cloud-save/download-game-artifact.ts b/src/main/events/cloud-save/download-game-artifact.ts index d0e8d845..49c0b4f9 100644 --- a/src/main/events/cloud-save/download-game-artifact.ts +++ b/src/main/events/cloud-save/download-game-artifact.ts @@ -42,6 +42,7 @@ const replaceLudusaviBackupWithCurrentUser = ( // Directories are different, rename if (backupHomeDir !== currentHomeDir) { if (fs.existsSync(newPath)) { + // Ensures that the destination is empty fs.rmSync(newPath, { recursive: true, force: true, diff --git a/src/main/events/cloud-save/upload-save-game.ts b/src/main/events/cloud-save/upload-save-game.ts index 919cfd9e..b7e48d77 100644 --- a/src/main/events/cloud-save/upload-save-game.ts +++ b/src/main/events/cloud-save/upload-save-game.ts @@ -13,6 +13,11 @@ import { app } from "electron"; const bundleBackup = async (shop: GameShop, objectId: string) => { const backupPath = path.join(backupsPath, `${shop}-${objectId}`); + // Remove existing backup + if (fs.existsSync(backupPath)) { + fs.rmSync(backupPath, { recursive: true }); + } + await Ludusavi.backupGame(shop, objectId, backupPath); const tarLocation = path.join(backupsPath, `${crypto.randomUUID()}.zip`);