mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-13 11:42:10 +00:00
feat: kill aria2c
This commit is contained in:
parent
d353002eab
commit
34a44e7fa9
2 changed files with 19 additions and 2 deletions
|
@ -3,7 +3,12 @@ import updater from "electron-updater";
|
|||
import i18n from "i18next";
|
||||
import path from "node:path";
|
||||
import { electronApp, optimizer } from "@electron-toolkit/utils";
|
||||
import { logger, resolveDatabaseUpdates, WindowManager } from "@main/services";
|
||||
import {
|
||||
DownloadManager,
|
||||
logger,
|
||||
resolveDatabaseUpdates,
|
||||
WindowManager,
|
||||
} from "@main/services";
|
||||
import { dataSource } from "@main/data-source";
|
||||
import * as resources from "@locales";
|
||||
import { userPreferencesRepository } from "@main/repository";
|
||||
|
@ -100,6 +105,10 @@ app.on("window-all-closed", () => {
|
|||
WindowManager.mainWindow = null;
|
||||
});
|
||||
|
||||
app.on("before-quit", () => {
|
||||
DownloadManager.disconnect();
|
||||
});
|
||||
|
||||
app.on("activate", () => {
|
||||
// On OS X it's common to re-create a window in the app when the
|
||||
// dock icon is clicked and there are no other windows open.
|
||||
|
|
|
@ -13,6 +13,7 @@ import { Game } from "@main/entity";
|
|||
import { startAria2 } from "./aria2c";
|
||||
import { sleep } from "@main/helpers";
|
||||
import { logger } from "./logger";
|
||||
import type { ChildProcess } from "node:child_process";
|
||||
|
||||
export class DownloadManager {
|
||||
private static downloads = new Map<number, string>();
|
||||
|
@ -21,11 +22,12 @@ export class DownloadManager {
|
|||
private static gid: string | null = null;
|
||||
private static game: Game | null = null;
|
||||
private static realDebridTorrentId: string | null = null;
|
||||
private static aria2c: ChildProcess | null = null;
|
||||
|
||||
private static aria2 = new Aria2({});
|
||||
|
||||
private static async connect() {
|
||||
startAria2();
|
||||
this.aria2c = startAria2();
|
||||
|
||||
let retries = 0;
|
||||
|
||||
|
@ -43,6 +45,12 @@ export class DownloadManager {
|
|||
}
|
||||
}
|
||||
|
||||
public static disconnect() {
|
||||
if (this.aria2c) {
|
||||
this.aria2c.kill();
|
||||
}
|
||||
}
|
||||
|
||||
private static getETA(
|
||||
totalLength: number,
|
||||
completedLength: number,
|
||||
|
|
Loading…
Reference in a new issue