diff --git a/binaries/hydra-httpdl.exe b/binaries/hydra-httpdl.exe new file mode 100644 index 00000000..7a686d9e Binary files /dev/null and b/binaries/hydra-httpdl.exe differ diff --git a/src/main/events/library/delete-game-folder.ts b/src/main/events/library/delete-game-folder.ts index 9c290fe0..b9cef25b 100644 --- a/src/main/events/library/delete-game-folder.ts +++ b/src/main/events/library/delete-game-folder.ts @@ -13,35 +13,42 @@ const deleteGameFolder = async ( objectId: string ): Promise => { const downloadKey = levelKeys.game(shop, objectId); - const download = await downloadsSublevel.get(downloadKey); - if (!download) return; + if (!download?.folderName) return; - if (download.folderName) { - const folderPath = path.join( - download.downloadPath ?? (await getDownloadsPath()), - download.folderName - ); + const folderPath = path.join( + download.downloadPath ?? (await getDownloadsPath()), + download.folderName + ); - if (fs.existsSync(folderPath)) { + const metaPath = `${folderPath}.meta`; + + const deleteFile = async (filePath: string, isDirectory = false) => { + if (fs.existsSync(filePath)) { await new Promise((resolve, reject) => { fs.rm( - folderPath, - { recursive: true, force: true, maxRetries: 5, retryDelay: 200 }, + filePath, + { + recursive: isDirectory, + force: true, + maxRetries: 5, + retryDelay: 200, + }, (error) => { if (error) { logger.error(error); reject(); } - resolve(); } ); }); } - } + }; + await deleteFile(folderPath, true); + await deleteFile(metaPath); await downloadsSublevel.del(downloadKey); }; diff --git a/src/main/services/python-rpc.ts b/src/main/services/python-rpc.ts index f3ad1fb0..8b717b0b 100644 --- a/src/main/services/python-rpc.ts +++ b/src/main/services/python-rpc.ts @@ -32,6 +32,10 @@ export class PythonRPC { public static readonly RPC_PORT = "8084"; private static readonly RPC_PASSWORD = crypto.randomBytes(32).toString("hex"); + private static readonly binaryPath = app.isPackaged + ? path.join(process.resourcesPath, "hydra-httpdl.exe") + : path.join(__dirname, "..", "..", "binaries", "hydra-httpdl.exe"); + private static pythonProcess: cp.ChildProcess | null = null; public static readonly rpc = axios.create({ diff --git a/src/types/level.types.ts b/src/types/level.types.ts index 21836870..eb48ced4 100644 --- a/src/types/level.types.ts +++ b/src/types/level.types.ts @@ -81,6 +81,7 @@ export interface UserPreferences { enableAutoInstall?: boolean; seedAfterDownloadComplete?: boolean; showHiddenAchievementsDescription?: boolean; + showDownloadSpeedInMegabits?: boolean; downloadNotificationsEnabled?: boolean; repackUpdatesNotificationsEnabled?: boolean; achievementNotificationsEnabled?: boolean;