Skip to content

Commit

Permalink
Deletes the unzipped folder even if there is an error
Browse files Browse the repository at this point in the history
  • Loading branch information
SaptakS committed Dec 20, 2024
1 parent d5b23ab commit 6f560a6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
7 changes: 2 additions & 5 deletions src/account_x.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1764,15 +1764,12 @@ export class XAccountController {
}

// Delete the unzipped X archive once the build is completed
async deleteUnzippedXArchive(archivePath: string): Promise<string | null> {
fs.rm(archivePath, { recursive: true}, err => {
async deleteUnzippedXArchive(archivePath: string): Promise<void> {
fs.rm(archivePath, { recursive: true, force: true }, err => {
if (err) {
log.error(`XAccountController.deleteUnzippedXArchive: Error occured while deleting unzipped folder: ${err}`);
return `Error occured while deleting unzipped folder: ${err}`;
}
});

return null;
}

// Return null on success, and a string (error message) on error
Expand Down
10 changes: 3 additions & 7 deletions src/renderer/src/views/x/XWizardImportingPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const startClicked = async () => {
statusValidating.value = ImportStatus.Failed;
errorMessages.value.push(verifyResp);
importFailed.value = true;
await window.electron.X.deleteUnzippedXArchive(props.model.account.id, unzippedPath);
return;
}
statusValidating.value = ImportStatus.Finished;
Expand Down Expand Up @@ -110,19 +111,14 @@ const startClicked = async () => {
statusBuildCydArchive.value = ImportStatus.Failed;
errorMessages.value.push(`${e}`);
importFailed.value = true;
await window.electron.X.deleteUnzippedXArchive(props.model.account.id, unzippedPath);
return;
}
emitter.emit(`x-update-archive-info-${props.model.account.id}`);
statusBuildCydArchive.value = ImportStatus.Finished;
// Delete the unarchived folder whether it's success or fail
const deleteResp: string | null = await window.electron.X.deleteUnzippedXArchive(props.model.account.id, unzippedPath);
if (deleteResp !== null) {
statusValidating.value = ImportStatus.Failed;
errorMessages.value.push(verifyResp);
importFailed.value = true;
return;
}
await window.electron.X.deleteUnzippedXArchive(props.model.account.id, unzippedPath);
// Success
if (!importFailed.value) {
Expand Down

0 comments on commit 6f560a6

Please sign in to comment.