Skip to content

Commit

Permalink
Don't copy new files if destination path is the same
Browse files Browse the repository at this point in the history
  • Loading branch information
tillvit committed Dec 18, 2024
1 parent dbe69d9 commit fedebde
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions app/src/gui/window/NewSongWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down

0 comments on commit fedebde

Please sign in to comment.