mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
chore: resolving merge conflict on downloads
This commit is contained in:
commit
d123f63095
5 changed files with 56 additions and 41 deletions
|
@ -1,8 +1,6 @@
|
|||
import path from "node:path";
|
||||
import fs from "node:fs";
|
||||
|
||||
import { In } from "typeorm";
|
||||
|
||||
import { gameRepository } from "@main/repository";
|
||||
|
||||
import { getDownloadsPath } from "../helpers/get-downloads-path";
|
||||
|
@ -14,11 +12,18 @@ const deleteGameFolder = async (
|
|||
gameId: number
|
||||
): Promise<void> => {
|
||||
const game = await gameRepository.findOne({
|
||||
where: {
|
||||
where: [
|
||||
{
|
||||
id: gameId,
|
||||
status: In(["removed", "complete"]),
|
||||
isDeleted: false,
|
||||
status: "removed",
|
||||
},
|
||||
{
|
||||
id: gameId,
|
||||
progress: 1,
|
||||
isDeleted: false,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
if (!game) return;
|
||||
|
@ -29,8 +34,14 @@ const deleteGameFolder = async (
|
|||
game.folderName
|
||||
);
|
||||
|
||||
if (fs.existsSync(folderPath)) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!fs.existsSync(folderPath)) {
|
||||
await gameRepository.update(
|
||||
{ id: gameId },
|
||||
{ downloadPath: null, folderName: null }
|
||||
);
|
||||
}
|
||||
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
fs.rm(
|
||||
folderPath,
|
||||
{ recursive: true, force: true, maxRetries: 5, retryDelay: 200 },
|
||||
|
@ -43,9 +54,13 @@ const deleteGameFolder = async (
|
|||
resolve();
|
||||
}
|
||||
);
|
||||
}).then(async () => {
|
||||
await gameRepository.update(
|
||||
{ id: gameId },
|
||||
{ downloadPath: null, folderName: null }
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
registerEvent("deleteGameFolder", deleteGameFolder);
|
||||
|
|
|
@ -30,6 +30,6 @@ export const getSteamAppDetails = async (
|
|||
})
|
||||
.catch((err) => {
|
||||
logger.error(err, { method: "getSteamAppDetails" });
|
||||
throw new Error(err);
|
||||
return null;
|
||||
});
|
||||
};
|
||||
|
|
|
@ -52,7 +52,6 @@ export function useDownload() {
|
|||
|
||||
try {
|
||||
await window.electron.deleteGameFolder(gameId);
|
||||
await window.electron.removeGame(gameId);
|
||||
updateLibrary();
|
||||
} finally {
|
||||
dispatch(removeGameFromDeleting(gameId));
|
||||
|
|
|
@ -69,7 +69,7 @@ export function Downloads() {
|
|||
);
|
||||
|
||||
const complete = orderBy(result.complete, (game) =>
|
||||
game.status === "complete" ? 0 : 1
|
||||
game.progress === 1 ? 0 : 1
|
||||
);
|
||||
|
||||
return {
|
||||
|
|
|
@ -110,11 +110,6 @@ export function HeroPanelActions() {
|
|||
return;
|
||||
}
|
||||
|
||||
if (game?.executablePath) {
|
||||
window.electron.openGame(game.id, game.executablePath);
|
||||
return;
|
||||
}
|
||||
|
||||
const gameExecutablePath = await selectGameExecutable();
|
||||
if (gameExecutablePath)
|
||||
window.electron.openGame(game.id, gameExecutablePath);
|
||||
|
@ -139,6 +134,17 @@ export function HeroPanelActions() {
|
|||
</Button>
|
||||
);
|
||||
|
||||
const showDownloadOptionsButton = (
|
||||
<Button
|
||||
onClick={openRepacksModal}
|
||||
theme="outline"
|
||||
disabled={deleting}
|
||||
className={styles.heroPanelAction}
|
||||
>
|
||||
{t("open_download_options")}
|
||||
</Button>
|
||||
);
|
||||
|
||||
if (game?.status === "active" && game?.progress !== 1) {
|
||||
return (
|
||||
<>
|
||||
|
@ -188,14 +194,7 @@ export function HeroPanelActions() {
|
|||
if (game?.status === "removed") {
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
onClick={openRepacksModal}
|
||||
theme="outline"
|
||||
disabled={deleting}
|
||||
className={styles.heroPanelAction}
|
||||
>
|
||||
{t("open_download_options")}
|
||||
</Button>
|
||||
{showDownloadOptionsButton}
|
||||
|
||||
<Button
|
||||
onClick={() => removeGameFromLibrary(game.id).then(updateGame)}
|
||||
|
@ -227,7 +226,7 @@ export function HeroPanelActions() {
|
|||
if (game) {
|
||||
return (
|
||||
<>
|
||||
{game?.progress === 1 ? (
|
||||
{game.progress === 1 && game.downloadPath && (
|
||||
<>
|
||||
<BinaryNotFoundModal
|
||||
visible={showBinaryNotFoundModal}
|
||||
|
@ -243,10 +242,12 @@ export function HeroPanelActions() {
|
|||
{t("install")}
|
||||
</Button>
|
||||
</>
|
||||
) : (
|
||||
toggleGameOnLibraryButton
|
||||
)}
|
||||
|
||||
{game.progress === 1 && !game.downloadPath && showDownloadOptionsButton}
|
||||
|
||||
{game.progress !== 1 && toggleGameOnLibraryButton}
|
||||
|
||||
{isGameRunning ? (
|
||||
<Button
|
||||
onClick={closeGame}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue