fix: merge with ci

This commit is contained in:
Chubby Granny Chaser
2025-04-12 19:58:18 +01:00
23 changed files with 3169 additions and 367 deletions

View File

@@ -354,7 +354,8 @@
"common_redist": "Common redistributables",
"common_redist_description": "Common redistributables are required to run some games. Installing them is recommended to avoid issues.",
"install_common_redist": "Install",
"installing_common_redist": "Installing…"
"installing_common_redist": "Installing…",
"show_download_speed_in_megabits": "Show download speed in megabits per second"
},
"notifications": {
"download_complete": "Download complete",

View File

@@ -341,7 +341,8 @@
"common_redist": "Componentes recomendados",
"common_redist_description": "Componentes recomendados são necessários para executar alguns jogos. A instalação deles é recomendada para evitar problemas.",
"install_common_redist": "Instalar",
"installing_common_redist": "Instalando…"
"installing_common_redist": "Instalando…",
"show_download_speed_in_megabits": "Exibir taxas de download em megabits por segundo"
},
"notifications": {
"download_complete": "Download concluído",

View File

@@ -8,7 +8,6 @@ import { electronApp, optimizer } from "@electron-toolkit/utils";
import { logger, WindowManager } from "@main/services";
import resources from "@locales";
import { PythonRPC } from "./services/python-rpc";
import { Aria2 } from "./services/aria2";
import { db, levelKeys } from "./level";
import { loadState } from "./main";
@@ -143,7 +142,6 @@ app.on("window-all-closed", () => {
app.on("before-quit", () => {
/* Disconnects libtorrent */
PythonRPC.kill();
Aria2.kill();
});
app.on("activate", () => {

View File

@@ -2,7 +2,6 @@ import { DownloadManager, Ludusavi, startMainLoop } from "./services";
import { RealDebridClient } from "./services/download/real-debrid";
import { HydraApi } from "./services/hydra-api";
import { uploadGamesBatch } from "./services/library-sync";
import { Aria2 } from "./services/aria2";
import { downloadsSublevel } from "./level/sublevels/downloads";
import { sortBy } from "lodash-es";
import { Downloader } from "@shared";
@@ -21,8 +20,6 @@ export const loadState = async () => {
await import("./events");
Aria2.spawn();
if (userPreferences?.realDebridApiToken) {
RealDebridClient.authorize(userPreferences.realDebridApiToken);
}

View File

@@ -1,28 +0,0 @@
import path from "node:path";
import cp from "node:child_process";
import { app } from "electron";
export class Aria2 {
private static process: cp.ChildProcess | null = null;
private static readonly binaryPath = app.isPackaged
? path.join(process.resourcesPath, "aria2", "aria2c")
: path.join(__dirname, "..", "..", "aria2", "aria2c");
public static spawn() {
this.process = cp.spawn(
this.binaryPath,
[
"--enable-rpc",
"--rpc-listen-all",
"--file-allocation=none",
"--allow-overwrite=true",
"--disk-cache=64M",
],
{ stdio: "inherit", windowsHide: true }
);
}
public static kill() {
this.process?.kill();
}
}

View File

@@ -372,6 +372,7 @@ export class DownloadManager {
game_id: downloadId,
url: downloadUrl,
save_path: download.downloadPath,
allow_multiple_connections: true,
};
}
case Downloader.TorBox: {
@@ -384,6 +385,7 @@ export class DownloadManager {
url,
save_path: download.downloadPath,
out: name,
allow_multiple_connections: true,
};
}
case Downloader.Hydra: {
@@ -398,6 +400,7 @@ export class DownloadManager {
game_id: downloadId,
url: downloadUrl,
save_path: download.downloadPath,
allow_multiple_connections: true,
};
}
}

View File

@@ -21,6 +21,12 @@ const binaryNameByPlatform: Partial<Record<NodeJS.Platform, string>> = {
win32: "hydra-python-rpc.exe",
};
const rustBinaryNameByPlatform: Partial<Record<NodeJS.Platform, string>> = {
darwin: "hydra-httpdl",
linux: "hydra-httpdl",
win32: "hydra-httpdl.exe",
};
export class PythonRPC {
public static readonly BITTORRENT_PORT = "5881";
public static readonly RPC_PORT = "8084";
@@ -52,6 +58,20 @@ export class PythonRPC {
this.RPC_PASSWORD,
initialDownload ? JSON.stringify(initialDownload) : "",
initialSeeding ? JSON.stringify(initialSeeding) : "",
app.isPackaged
? path.join(
process.resourcesPath,
rustBinaryNameByPlatform[process.platform]!
)
: path.join(
__dirname,
"..",
"..",
"rust_rpc",
"target",
"debug",
rustBinaryNameByPlatform[process.platform]!
),
];
if (app.isPackaged) {

View File

@@ -138,6 +138,7 @@ export function App() {
}, [fetchUserDetails, updateUserDetails, dispatch]);
const syncDownloadSources = useCallback(async () => {
console.log("SYNC CALLED");
const downloadSources = await window.electron.getDownloadSources();
const existingDownloadSources: DownloadSource[] =

View File

@@ -15,12 +15,14 @@ import type {
StartGameDownloadPayload,
} from "@types";
import { useDate } from "./use-date";
import { formatBytes } from "@shared";
import { formatBytes, formatBytesToMbps } from "@shared";
export function useDownload() {
const { updateLibrary } = useLibrary();
const { formatDistance } = useDate();
const userPrefs = useAppSelector((state) => state.userPreferences.value);
const { lastPacket, gamesWithDeletionInProgress } = useAppSelector(
(state) => state.download
);
@@ -99,8 +101,14 @@ export function useDownload() {
return gamesWithDeletionInProgress.includes(objectId);
};
const formatDownloadSpeed = (downloadSpeed: number): string => {
return userPrefs?.showDownloadSpeedInMegabits
? `${formatBytes(downloadSpeed)}/s`
: formatBytesToMbps(downloadSpeed);
};
return {
downloadSpeed: `${formatBytes(lastPacket?.downloadSpeed ?? 0)}/s`,
downloadSpeed: formatDownloadSpeed(lastPacket?.downloadSpeed ?? 0),
progress: formatDownloadProgress(lastPacket?.progress ?? 0),
lastPacket,
eta: calculateETA(),

View File

@@ -23,6 +23,7 @@ export function SettingsBehavior() {
enableAutoInstall: false,
seedAfterDownloadComplete: false,
showHiddenAchievementsDescription: false,
showDownloadSpeedInMegabits: false,
});
const { t } = useTranslation("settings");
@@ -40,6 +41,8 @@ export function SettingsBehavior() {
userPreferences.seedAfterDownloadComplete ?? false,
showHiddenAchievementsDescription:
userPreferences.showHiddenAchievementsDescription ?? false,
showDownloadSpeedInMegabits:
userPreferences.showDownloadSpeedInMegabits ?? false,
});
}
}, [userPreferences]);
@@ -139,6 +142,16 @@ export function SettingsBehavior() {
})
}
/>
<CheckboxField
label={t("show_download_speed_in_megabits")}
checked={form.showDownloadSpeedInMegabits}
onChange={() =>
handleChange({
showDownloadSpeedInMegabits: !form.showDownloadSpeedInMegabits,
})
}
/>
</>
);
}

View File

@@ -49,6 +49,12 @@ export const formatBytes = (bytes: number): string => {
return `${Math.trunc(formatedByte * 10) / 10} ${FORMAT[base]}`;
};
export const formatBytesToMbps = (bytesPerSecond: number): string => {
const bitsPerSecond = bytesPerSecond * 8;
const mbps = bitsPerSecond / (1024 * 1024);
return `${Math.trunc(mbps * 10) / 10} Mbps`;
};
export const pipe =
<T>(...fns: ((arg: T) => any)[]) =>
(arg: T) =>

View File

@@ -85,6 +85,7 @@ export interface UserPreferences {
repackUpdatesNotificationsEnabled?: boolean;
achievementNotificationsEnabled?: boolean;
friendRequestNotificationsEnabled?: boolean;
showDownloadSpeedInMegabits?: boolean;
}
export interface ScreenState {