Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:electron: Copy budget files to succeed even if cleanup fails & adding retries #4507

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion packages/desktop-electron/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,14 +554,39 @@ ipcMain.handle(

await copy(currentBudgetDirectory, newDirectory, {
overwrite: true,
preserveTimestamps: true,
});
await remove(currentBudgetDirectory);
} catch (error) {
logMessage(
'error',
`There was an error moving your directory: ${error}`,
);
throw error;
}

try {
await promiseRetry(
async retry => {
try {
return await remove(currentBudgetDirectory);
} catch (error) {
logMessage(
'info',
`Retrying: Clean up old directory: ${currentBudgetDirectory}`,
);

retry(error);
}
},
{ minTimeout: 200, maxTimeout: 500, factor: 1.25 },
);
} catch (error) {
// Fail silently. The move worked, but the old directory wasn't cleaned up - most likely a permission issue.
// This call needs to succeed to allow the user to continue using the app with the files in the new location.
logMessage(
'error',
`There was an error removing the old directory: ${error}`,
);
}
},
);
2 changes: 1 addition & 1 deletion packages/desktop-electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
},
"dependencies": {
"better-sqlite3": "^11.7.0",
"fs-extra": "^11.2.0",
"fs-extra": "^11.3.0",
"promise-retry": "^2.0.1"
},
"devDependencies": {
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/4507.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [MikesGlitch]
---

Allow desktop app to move budget files even when cleanup tasks fail
15 changes: 13 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10172,7 +10172,7 @@ __metadata:
cross-env: "npm:^7.0.3"
electron: "npm:30.0.6"
electron-builder: "npm:24.13.3"
fs-extra: "npm:^11.2.0"
fs-extra: "npm:^11.3.0"
promise-retry: "npm:^2.0.1"
typescript: "npm:^5.5.4"
languageName: unknown
Expand Down Expand Up @@ -12425,7 +12425,7 @@ __metadata:
languageName: node
linkType: hard

"fs-extra@npm:^11.1.0, fs-extra@npm:^11.2.0":
"fs-extra@npm:^11.1.0":
version: 11.2.0
resolution: "fs-extra@npm:11.2.0"
dependencies:
Expand All @@ -12436,6 +12436,17 @@ __metadata:
languageName: node
linkType: hard

"fs-extra@npm:^11.3.0":
version: 11.3.0
resolution: "fs-extra@npm:11.3.0"
dependencies:
graceful-fs: "npm:^4.2.0"
jsonfile: "npm:^6.0.1"
universalify: "npm:^2.0.0"
checksum: 10/c9fe7b23dded1efe7bbae528d685c3206477e20cc60e9aaceb3f024f9b9ff2ee1f62413c161cb88546cc564009ab516dec99e9781ba782d869bb37e4fe04a97f
languageName: node
linkType: hard

"fs-extra@npm:^8.0.1, fs-extra@npm:^8.1.0":
version: 8.1.0
resolution: "fs-extra@npm:8.1.0"
Expand Down