diff --git a/.changeset/dest-already-exists.md b/.changeset/dest-already-exists.md new file mode 100644 index 000000000..819755826 --- /dev/null +++ b/.changeset/dest-already-exists.md @@ -0,0 +1,5 @@ +--- +ggt: patch +--- + +Attempt to fix `Error: dest already exists.` by moving files one at a time to `.gadget/backup/`. diff --git a/src/services/filesync/filesync.ts b/src/services/filesync/filesync.ts index b5492fc96..f9e468c43 100644 --- a/src/services/filesync/filesync.ts +++ b/src/services/filesync/filesync.ts @@ -22,7 +22,6 @@ import { } from "../app/edit/operation.js"; import type { Command } from "../command/command.js"; import type { Context } from "../command/context.js"; -import { config } from "../config/config.js"; import { confirm } from "../output/confirm.js"; import type { Fields } from "../output/log/field.js"; import { Level } from "../output/log/level.js"; @@ -622,7 +621,7 @@ export class FileSync { const changes = new Changes(); const directoriesWithDeletedFiles = new Set(); - await pMap(options.delete, async (pathToDelete) => { + for (const pathToDelete of options.delete.sort().reverse()) { // add all the directories that contain this file to // directoriesWithDeletedFiles so we can clean them up later let dir = path.dirname(pathToDelete); @@ -674,16 +673,14 @@ export class FileSync { } }, { - // windows tends to run into these issues way more often than - // mac/linux, so we retry more times - retries: config.windows ? 4 : 2, + retries: 5, minTimeout: ms("100ms"), onFailedAttempt: (error) => { ctx.log.warn("failed to move file to backup", { error, currentPath, backupPath }); }, }, ); - }); + } for (const directoryWithDeletedFile of Array.from(directoriesWithDeletedFiles.values()).sort().reverse()) { if (options.files.some((file) => file.path === directoryWithDeletedFile)) {