fix: fixing downloads screen

This commit is contained in:
Chubby Granny Chaser
2024-05-20 15:07:52 +01:00
parent 4941709296
commit da607fe741
5 changed files with 48 additions and 48 deletions

View File

@@ -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);
}

View File

@@ -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(

View File

@@ -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 },