From fedebdeb3d1bd3a3db9476404921172454577de9 Mon Sep 17 00:00:00 2001 From: tillvit Date: Tue, 17 Dec 2024 17:57:23 -0800 Subject: [PATCH] Don't copy new files if destination path is the same --- app/src/gui/window/NewSongWindow.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/app/src/gui/window/NewSongWindow.ts b/app/src/gui/window/NewSongWindow.ts index 32055e0..79aa0bf 100644 --- a/app/src/gui/window/NewSongWindow.ts +++ b/app/src/gui/window/NewSongWindow.ts @@ -140,6 +140,7 @@ export class NewSongWindow extends Window { let folder = this.sm.properties.TITLE! if (window.nw) { const path = nw.require("path") + const process = nw.require("process") const fileSelector = document.createElement("input") fileSelector.type = "file" fileSelector.nwsaveas = folder + ".sm" @@ -153,9 +154,18 @@ export class NewSongWindow extends Window { await FileHandler.writeFile(smPath, this.sm.serialize("sm")) // Add the rest of the files await Promise.all( - Object.entries(this.fileTable).map(entry => - FileHandler.writeFile(folder + `/${entry[0]}`, entry[1]) - ) + Object.entries(this.fileTable).map(entry => { + const newPath = path.resolve(path.join(folder, entry[0])) + const filePath = path.resolve(entry[1].path!) + // Don't copy if they are the same path + if ( + process.platform == "win32" && + newPath.toLowerCase() === filePath.toLowerCase() + ) + return + if (newPath === filePath) return + return FileHandler.writeFile(newPath, entry[1]) + }) ) await this.app.chartManager.loadSM(smPath) this.app.windowManager