feat: disabling button when installing

This commit is contained in:
Chubby Granny Chaser
2025-04-07 00:00:43 +01:00
parent 417bb69b86
commit 3bb8c17b16
2 changed files with 31 additions and 32 deletions

View File

@@ -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();
}
});
};

View File

@@ -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();
}
);