Merge branch 'feature/add-download-sources' into feature/game-options-modal

This commit is contained in:
Zamitto
2024-06-05 16:17:49 -03:00
17 changed files with 343 additions and 146 deletions

View File

@@ -34,33 +34,32 @@ const deleteGameFolder = async (
game.folderName
);
if (!fs.existsSync(folderPath)) {
await gameRepository.update(
{ id: gameId },
{ downloadPath: null, folderName: null }
);
}
if (fs.existsSync(folderPath)) {
await new Promise<void>((resolve, reject) => {
fs.rm(
folderPath,
{ recursive: true, force: true, maxRetries: 5, retryDelay: 200 },
(error) => {
if (error) {
logger.error(error);
reject();
}
return new Promise<void>((resolve, reject) => {
fs.rm(
folderPath,
{ recursive: true, force: true, maxRetries: 5, retryDelay: 200 },
(error) => {
if (error) {
logger.error(error);
reject();
const aria2ControlFilePath = `${folderPath}.aria2`;
if (fs.existsSync(aria2ControlFilePath))
fs.rmSync(aria2ControlFilePath);
resolve();
}
resolve();
}
);
}).then(async () => {
await gameRepository.update(
{ id: gameId },
{ downloadPath: null, folderName: null }
);
});
);
});
}
}
await gameRepository.update(
{ id: gameId },
{ downloadPath: null, folderName: null, status: null, progress: 0 }
);
};
registerEvent("deleteGameFolder", deleteGameFolder);