mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-29 22:01:03 +00:00
fix: fixing downloads screen
This commit is contained in:
@@ -20,7 +20,7 @@ const resumeGameDownload = async (
|
||||
if (game.status === "paused") {
|
||||
await DownloadManager.pauseDownload();
|
||||
|
||||
await gameRepository.update({ status: "active" }, { status: "paused" });
|
||||
await gameRepository.update({ id: gameId }, { status: "active" });
|
||||
|
||||
await DownloadManager.resumeDownload(gameId);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import { getFileBase64, getSteamAppAsset } from "@main/helpers";
|
||||
import { DownloadManager } from "@main/services";
|
||||
import { Downloader } from "@shared";
|
||||
import { stateManager } from "@main/state-manager";
|
||||
import { Not } from "typeorm";
|
||||
|
||||
const startGameDownload = async (
|
||||
_event: Electron.IpcMainInvokeEvent,
|
||||
@@ -43,7 +44,10 @@ const startGameDownload = async (
|
||||
|
||||
if (!repack || game?.status === "active") return;
|
||||
|
||||
await gameRepository.update({ status: "active" }, { status: "paused" });
|
||||
await gameRepository.update(
|
||||
{ status: "active", progress: Not(1) },
|
||||
{ status: "paused" }
|
||||
);
|
||||
|
||||
if (game) {
|
||||
await gameRepository.update(
|
||||
|
||||
@@ -10,6 +10,8 @@ import { Notification } from "electron";
|
||||
import { t } from "i18next";
|
||||
import { Downloader } from "@shared";
|
||||
import { DownloadProgress } from "@types";
|
||||
import { QueryDeepPartialEntity } from "typeorm/query-builder/QueryPartialEntity";
|
||||
import { Game } from "@main/entity";
|
||||
|
||||
export class DownloadManager {
|
||||
private static downloads = new Map<number, string>();
|
||||
@@ -94,17 +96,24 @@ export class DownloadManager {
|
||||
const progress =
|
||||
Number(status.completedLength) / Number(status.totalLength);
|
||||
|
||||
await gameRepository.update(
|
||||
{ id: this.gameId },
|
||||
{
|
||||
progress:
|
||||
isNaN(progress) || downloadingMetadata ? undefined : progress,
|
||||
if (!downloadingMetadata) {
|
||||
const update: QueryDeepPartialEntity<Game> = {
|
||||
bytesDownloaded: Number(status.completedLength),
|
||||
fileSize: Number(status.totalLength),
|
||||
status: status.status,
|
||||
folderName: this.getFolderName(status),
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
if (!isNaN(progress)) update.progress = progress;
|
||||
|
||||
await gameRepository.update(
|
||||
{ id: this.gameId },
|
||||
{
|
||||
...update,
|
||||
status: status.status,
|
||||
folderName: this.getFolderName(status),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
const game = await gameRepository.findOne({
|
||||
where: { id: this.gameId, isDeleted: false },
|
||||
|
||||
Reference in New Issue
Block a user