diff --git a/src/main/services/7zip.ts b/src/main/services/7zip.ts index 57987f90..08abf389 100644 --- a/src/main/services/7zip.ts +++ b/src/main/services/7zip.ts @@ -32,7 +32,8 @@ export class SevenZip { cwd?: string; passwords?: string[]; }, - cb: (success: boolean) => void + successCb: () => void, + errorCb: () => void ) { const tryPassword = (index = -1) => { const password = passwords[index] ?? ""; @@ -52,7 +53,7 @@ export class SevenZip { console.log("EXIT CALLED", code, filePath); if (code === 0) { - cb(true); + successCb(); return; } @@ -65,7 +66,7 @@ export class SevenZip { } else { logger.info(`Failed to extract file: ${filePath}`); - cb(false); + errorCb(); } }); }; diff --git a/src/main/services/game-files-manager.ts b/src/main/services/game-files-manager.ts index d97141fd..120b3e8f 100644 --- a/src/main/services/game-files-manager.ts +++ b/src/main/services/game-files-manager.ts @@ -51,13 +51,12 @@ export class GameFilesManager { cwd: directoryPath, passwords: ["online-fix.me", "steamrip.com"], }, - async (success) => { - if (success) { - resolve(true); - } else { - reject(new Error(`Failed to extract file: ${file}`)); - this.clearExtractionState(); - } + () => { + resolve(true); + }, + () => { + reject(new Error(`Failed to extract file: ${file}`)); + this.clearExtractionState(); } ); }); @@ -126,32 +125,31 @@ export class GameFilesManager { outputPath: extractionPath, passwords: ["online-fix.me", "steamrip.com"], }, - async (success) => { - if (success) { - await this.extractFilesInDirectory(extractionPath); + async () => { + await this.extractFilesInDirectory(extractionPath); - if (fs.existsSync(extractionPath) && fs.existsSync(filePath)) { - fs.unlink(filePath, (err) => { - if (err) { - logger.error( - `Failed to delete file: ${download.folderName}`, - err - ); + if (fs.existsSync(extractionPath) && fs.existsSync(filePath)) { + fs.unlink(filePath, (err) => { + if (err) { + logger.error( + `Failed to delete file: ${download.folderName}`, + err + ); - this.clearExtractionState(); - } - }); - } - - await downloadsSublevel.put(gameKey, { - ...download!, - folderName: path.parse(download.folderName!).name, + this.clearExtractionState(); + } }); - - this.setExtractionComplete(); - } else { - this.clearExtractionState(); } + + await downloadsSublevel.put(gameKey, { + ...download!, + folderName: path.parse(download.folderName!).name, + }); + + this.setExtractionComplete(); + }, + () => { + this.clearExtractionState(); } );