refactor: enhance download management by validating URLs and adding file size handling

This commit is contained in:
Moyasee
2026-01-24 19:38:00 +02:00
parent fb1380356e
commit eea7148108
8 changed files with 153 additions and 46 deletions

View File

@@ -69,10 +69,16 @@ export function useDownload() {
};
const cancelDownload = async (shop: GameShop, objectId: string) => {
await window.electron.cancelGameDownload(shop, objectId);
dispatch(clearDownload());
updateLibrary();
const gameId = `${shop}:${objectId}`;
const isActiveDownload = lastPacket?.gameId === gameId;
await window.electron.cancelGameDownload(shop, objectId);
if (isActiveDownload) {
dispatch(clearDownload());
}
updateLibrary();
removeGameInstaller(shop, objectId);
};

View File

@@ -112,6 +112,7 @@ export default function GameDetails() {
downloadPath,
uri: selectRepackUri(repack, downloader),
automaticallyExtract: automaticallyExtract,
fileSize: repack.fileSize,
})
: await startDownload({
objectId: objectId!,
@@ -121,6 +122,7 @@ export default function GameDetails() {
downloadPath,
uri: selectRepackUri(repack, downloader),
automaticallyExtract: automaticallyExtract,
fileSize: repack.fileSize,
});
if (response.ok) {