diff --git a/src/main/events/torrenting/resume-game-download.ts b/src/main/events/torrenting/resume-game-download.ts index 48bb1c12..80d1429f 100644 --- a/src/main/events/torrenting/resume-game-download.ts +++ b/src/main/events/torrenting/resume-game-download.ts @@ -13,7 +13,12 @@ const resumeGameDownload = async ( const download = await downloadsSublevel.get(gameKey); - if (download?.status === "paused") { + // Allow resuming if status is "paused" OR "active" (for cases where app was closed during download) + if ( + download && + (download.status === "paused" || download.status === "active") && + download.progress !== 1 + ) { await DownloadManager.pauseDownload(); for await (const [key, value] of downloadsSublevel.iterator()) { diff --git a/src/main/main.ts b/src/main/main.ts index 1cadcebd..c176efa7 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -1,5 +1,5 @@ import { downloadsSublevel } from "./level/sublevels/downloads"; -import { sortBy } from "lodash-es"; +import { orderBy } from "lodash-es"; import { Downloader } from "@shared"; import { levelKeys, db } from "./level"; import type { UserPreferences } from "@types"; @@ -68,7 +68,7 @@ export const loadState = async () => { .values() .all() .then((games) => { - return sortBy(games, "timestamp", "DESC"); + return orderBy(games, "timestamp", "desc"); }); downloads.forEach((download) => { diff --git a/src/main/services/download/download-manager.ts b/src/main/services/download/download-manager.ts index 4dcebbb0..1a79f8f0 100644 --- a/src/main/services/download/download-manager.ts +++ b/src/main/services/download/download-manager.ts @@ -20,7 +20,7 @@ import { RealDebridClient } from "./real-debrid"; import path from "path"; import { logger } from "../logger"; import { db, downloadsSublevel, gamesSublevel, levelKeys } from "@main/level"; -import { sortBy } from "lodash-es"; +import { orderBy } from "lodash-es"; import { TorBoxClient } from "./torbox"; import { GameFilesManager } from "../game-files-manager"; import { HydraDebridClient } from "./hydra-debrid"; @@ -194,10 +194,10 @@ export class DownloadManager { .values() .all() .then((games) => { - return sortBy( + return orderBy( games.filter((game) => game.status === "paused" && game.queued), "timestamp", - "DESC" + "desc" ); });