Skip to content

Commit

Permalink
Handle errors while changing the data folder
Browse files Browse the repository at this point in the history
- Catch all errors and show them in error modal. Previously at least
  AccessDenied errors while writing the dataDirectoryOverrideFile in
  TSMM went unhandled
- Update settings only after the dataDirectoryOverrideFile has been
  successfully created, since it's less likely to fail than writing on
  the disk
  • Loading branch information
anttimaki committed Apr 30, 2024
1 parent 4cd8d14 commit 2aea5bb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/pages/Manager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,9 @@ import CategoryFilterModal from '../components/modals/CategoryFilterModal.vue';
const isDefaultDataDirectory = files[0] === PathResolver.APPDATA_DIR;
if (hasOverrideFile || !directoryHasContents || isDefaultDataDirectory) {
await this.settings.setDataDirectory(files[0]);
// Write dataDirectoryOverrideFile to allow re-selection of directory if changed at a later point.
await fs.writeFile(path.join(files[0], dataDirectoryOverrideFile), "");
await this.settings.setDataDirectory(files[0]);
InteractionProvider.instance.restartApp();
} else {
this.$store.commit('error/handleError', new R2Error(
Expand All @@ -530,6 +530,11 @@ import CategoryFilterModal from '../components/modals/CategoryFilterModal.vue';
));
}
}
}).catch((err) => {
this.$store.commit(
"error/handleError",
R2Error.fromThrownValue(err, "Failed to change Data Folder")
);
});
}
Expand Down

0 comments on commit 2aea5bb

Please sign in to comment.