Skip to content

Commit

Permalink
Merge pull request #707 from silentrald/feat/706
Browse files Browse the repository at this point in the history
[feat-706] show DepotDownloader missing executable error
  • Loading branch information
Zagrios authored Dec 23, 2024
2 parents 5cfb2d9 + d74ba72 commit 972794d
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 28 deletions.
2 changes: 2 additions & 0 deletions assets/jsons/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@
"msg": {
"401": "Steam scheint uns Beat Saber nicht herunterladen zu lassen 😢",
"404": "Steam-Server können nicht kontaktiert werden.",
"ExeNotFoundWindows": "\"DepotDownloader.exe\" fehlt. Bitte überprüfen Sie, ob die ausführbare Datei von Ihrer Antivirensoftware quarantäneiert wurde.",
"ExeNotFoundLinux": "Die ausführbare Datei \"DepotDownloader\" fehlt.",
"Password": "Passwort ist ungültig.",
"InvalidCredentials": "Ungültige Anmeldedaten, nicht genehmigte Verbindung oder zu viele Anmeldeversuche.",
"NoManifest": "Es wurde kein Manifest gefunden.",
Expand Down
2 changes: 2 additions & 0 deletions assets/jsons/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@
"msg": {
"401": "Steam doesn't seem to want to let us download Beat Saber 😢",
"404": "Unable to contact Steam servers.",
"ExeNotFoundWindows": "\"DepotDownloader.exe\" is missing. Please check if the executable is quarantined by your anti-virus.",
"ExeNotFoundLinux": "\"DepotDownloader\" executable is missing.",
"Password": "Password is invalid.",
"InvalidCredentials": "Invalid login credentials, unapproved connection, or too many login attempts.",
"NoManifest": "No manifest was found",
Expand Down
2 changes: 2 additions & 0 deletions assets/jsons/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@
"msg": {
"401": "Parece que Steam no quiere dejarnos descargar Beat Saber 😢",
"404": "No se puede contactar con los servidores de Steam",
"ExeNotFoundWindows": "Falta \"DepotDownloader.exe\". Por favor, verifique si el ejecutable está en cuarentena por su antivirus.",
"ExeNotFoundLinux": "Falta el ejecutable de \"DepotDownloader\".",
"Password": "La contraseña es inválida.",
"InvalidCredentials": "Credenciales de inicio de sesión inválidas, conexión no aprobada o demasiados intentos de inicio de sesión.",
"NoManifest": "No se ha encontrado el manifiesto",
Expand Down
2 changes: 2 additions & 0 deletions assets/jsons/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@
"msg": {
"401": "Steam ne semble pas vouloir nous laisser télécharger Beat Saber 😢",
"404": "Impossible de contacter les serveurs de Steam.",
"ExeNotFoundWindows": "\"DepotDownloader.exe\" est manquant. Veuillez vérifier si l'exécutable est mis en quarantaine par votre antivirus.",
"ExeNotFoundLinux": "L'exécutable \"DepotDownloader\" est manquanto.",
"Password": "Le mot de passe est invalide.",
"InvalidCredentials": "Identifiants de connexion invalides, connexion non approuvée, ou trop de tentatives de connexion.",
"NoManifest": "Aucun manifest n'a été trouvé.",
Expand Down
2 changes: 2 additions & 0 deletions assets/jsons/translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@
"msg": {
"401": "SteamがBeat Saberのダウンロードを許可してくれないようだ。😢",
"404": "Steamサーバーに接続できません。",
"ExeNotFoundWindows": "「DepotDownloader.exe」が見つかりません。実行ファイルがアンチウイルスソフトによって隔離されていないか確認してください。",
"ExeNotFoundLinux": "「DepotDownloader」の実行ファイルが見つかりません。",
"Password": "パスワードが不正です。",
"InvalidCredentials": "無効なログイン認証情報、許可されていない接続、またはログイン試行回数が多すぎます。",
"NoManifest": "マニフェストは見つかりませんでした",
Expand Down
2 changes: 2 additions & 0 deletions assets/jsons/translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@
"msg": {
"401": "Steam이 Beat Saber 다운로드를 허용하지 않는 것 같습니다 😢",
"404": "Steam 서버에 연결할 수 없습니다.",
"ExeNotFoundWindows": "「DepotDownloader.exe」가 없습니다. 실행 파일이 바이러스 백신 프로그램에 의해 격리되었는지 확인하십시오.",
"ExeNotFoundLinux": "「DepotDownloader」 실행 파일이 없습니다.",
"Password": "비밀번호가 올바르지 않습니다.",
"InvalidCredentials": "유효하지 않은 로그인 자격 증명, 허가되지 않은 연결 또는 너무 많은 로그인 시도입니다.",
"NoManifest": "매니페스트를 찾을 수 없습니다",
Expand Down
2 changes: 2 additions & 0 deletions assets/jsons/translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@
"msg": {
"401": "Похоже Steam не хочет, чтобы мы скачали Beat Saber 😢",
"404": "Нет связи с серверами Steam.",
"ExeNotFoundWindows": "Отсутствует \"DepotDownloader.exe\". Пожалуйста, проверьте, не находится ли исполняемый файл в карантине вашего антивируса.",
"ExeNotFoundLinux": "Отсутствует исполняемый файл \"DepotDownloader\".",
"Password": "Неверный пароль.",
"InvalidCredentials": "Неверные учетные данные для входа, неразрешенное соединение или слишком много попыток входа.",
"NoManifest": "Файл манифеста не найден",
Expand Down
2 changes: 2 additions & 0 deletions assets/jsons/translations/zh-tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@
"msg": {
"401": "Steam 似乎不想讓我們下載 Beat Saber😢",
"404": "無法聯繫 Steam 伺服器。",
"ExeNotFoundWindows": "\"DepotDownloader.exe\" 缺失。請檢查執行檔是否被您的防毒軟體隔離。",
"ExeNotFoundLinux": "\"DepotDownloader\" 的可執行檔缺失。",
"Password": "密碼無效",
"InvalidCredentials": "登錄憑據無效、連接未經批准或登錄嘗試次數過多。",
"NoManifest": "未找到清單",
Expand Down
2 changes: 2 additions & 0 deletions assets/jsons/translations/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@
"msg": {
"401": "Steam 似乎不想让我们下载 Beat Saber😢",
"404": "无法联系 Steam 服务器。",
"ExeNotFoundWindows": "\"DepotDownloader.exe\" 缺失。请检查执行文件是否被您的防病毒软件隔离。",
"ExeNotFoundLinux": "\"DepotDownloader\" 的可执行文件缺失。",
"Password": "密码无效",
"InvalidCredentials": "登录凭据无效、连接未经批准或登录尝试次数过多。",
"NoManifest": "未找到清单",
Expand Down
42 changes: 30 additions & 12 deletions src/main/models/depot-downloader.class.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,56 @@
import path from "path";
import fs from "fs";
import { ChildProcessWithoutNullStreams, SpawnOptionsWithoutStdio, spawn } from "child_process";
import { Observable, ReplaySubject, Subscriber, filter, map, share } from "rxjs";
import { DepotDownloaderArgsOptions, DepotDownloaderErrorEvent, DepotDownloaderEvent, DepotDownloaderEventType, DepotDownloaderEventTypes, DepotDownloaderInfoEvent, DepotDownloaderWarningEvent } from "../../shared/models/bs-version-download/depot-downloader.model";
import { UtilsService } from 'main/services/utils.service';
import { CustomError } from "shared/models/exceptions/custom-error.class";

export class DepotDownloader {

private static readonly EXE_PATH = path.join(
UtilsService.getInstance().getAssetsScriptsPath(),
process.platform === "win32" ? "DepotDownloader.exe" : "DepotDownloader"
);

private process: ChildProcessWithoutNullStreams;
private processOut$: Observable<string>;
private subscriber: Subscriber<string>;


public constructor(
options: {
command: string, args?: string[], options?: SpawnOptionsWithoutStdio, echoStartData?: unknown
},
args?: string[], options?: SpawnOptionsWithoutStdio, echoStartData?: unknown
},
logger?: Logger
){
this.processOut$ = new Observable<string>(subscriber => {
) {
if (!fs.existsSync(DepotDownloader.EXE_PATH)) {
throw new CustomError(
"DepotDownloader executable not found",
process.platform === "win32"
? DepotDownloaderErrorEvent.ExeNotFoundWindows
: DepotDownloaderErrorEvent.ExeNotFoundLinux
);
}

this.processOut$ = new Observable<string>(subscriber => {
this.subscriber = subscriber;

this.process = spawn(options.command, options.args ?? [], options.options);
this.process = spawn(DepotDownloader.EXE_PATH, options.args ?? [], options.options);

subscriber.next(`[Info]|[Start]|${JSON.stringify(options.echoStartData) ?? ""}`);

this.process.stdout.on("data", data => {
const stringData: string = data.toString();

if(!stringData.includes(DepotDownloaderInfoEvent.Progress) && !stringData.includes(DepotDownloaderInfoEvent.Validated)){
logger?.info("DepotDownloader stdout:", stringData);
}

const lines: string[] = stringData.split("\n");
lines.forEach(line => subscriber.next(line));
});

this.process.on("error", error => subscriber.error(error));
this.process.stderr.on("error", error => subscriber.error(error));
this.process.on("exit", () => subscriber.complete());
Expand Down Expand Up @@ -74,7 +92,7 @@ export class DepotDownloader {
data: splitedLine[2],
}

}),
}),
filter(Boolean));
}

Expand All @@ -93,7 +111,7 @@ export class DepotDownloader {
const args: string[] = [];

for(const [key, value] of Object.entries(depotDownloaderArgs)){

if(value === true){
args.push(`-${key}`);
}
Expand All @@ -102,7 +120,7 @@ export class DepotDownloader {
args.push(`${value}`);
}
}

return args;
}

Expand All @@ -112,4 +130,4 @@ interface Logger {
info: (...args: unknown[]) => void,
warn: (...args: unknown[]) => void,
error: (...args: unknown[]) => void,
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { BS_APP_ID, BS_DEPOT } from "../../constants";
import path from "path";
import { BSVersion } from "shared/bs-version.interface";
import { UtilsService } from "../utils.service";
import log from "electron-log";
import { InstallationLocationService } from "../installation-location.service";
import { BSLocalVersionService } from "../bs-local-version.service";
Expand All @@ -17,14 +16,12 @@ import { CustomError } from "shared/models/exceptions/custom-error.class";
export class BsSteamDownloaderService {
private static instance: BsSteamDownloaderService;

private readonly utils: UtilsService;
private readonly installLocationService: InstallationLocationService;
private readonly localVersionService: BSLocalVersionService;

private depotDownloader: DepotDownloader;

private constructor() {
this.utils = UtilsService.getInstance();
this.installLocationService = InstallationLocationService.getInstance();
this.localVersionService = BSLocalVersionService.getInstance();

Expand All @@ -40,10 +37,6 @@ export class BsSteamDownloaderService {
return BsSteamDownloaderService.instance;
}

private getDepotDownloaderExePath(): string {
return path.join(this.utils.getAssetsScriptsPath(), process.platform === 'linux' ? "DepotDownloader" : "DepotDownloader.exe");
}

private async buildDepotDownloaderInstance(downloadInfos: DownloadSteamInfo, qr?: boolean): Promise<{depotDownloader: DepotDownloader, depotDownloaderOptions: DepotDownloaderArgsOptions, version: BSVersion}> {

const versionPath = await this.localVersionService.getVersionPath(downloadInfos.bsVersion);
Expand All @@ -68,11 +61,9 @@ export class BsSteamDownloaderService {

await ensureDir(this.installLocationService.versionsDirectory());

const exePath = this.getDepotDownloaderExePath();
const args = DepotDownloader.buildArgs(depotDownloaderOptions);

const depotDownloader = new DepotDownloader({
command: exePath,
args,
options: { cwd: this.installLocationService.versionsDirectory() },
echoStartData: downloadVersion
Expand Down Expand Up @@ -104,11 +95,21 @@ export class BsSteamDownloaderService {
finalize(() => this.localVersionService.initVersionMetadata(version, { store: BsStore.STEAM }))
).subscribe(sub);

}).catch(err => sub.error({
type: DepotDownloaderEventType.Error,
subType: DepotDownloaderErrorEvent.Unknown,
data: err
} as DepotDownloaderEvent));
}).catch(err => {
if (err instanceof CustomError
&& Object.values(DepotDownloaderErrorEvent).includes(
err.code as DepotDownloaderErrorEvent
)
) {
return sub.error(err);
}

return sub.error({
type: DepotDownloaderEventType.Error,
subType: DepotDownloaderErrorEvent.Unknown,
data: err
} as DepotDownloaderEvent)
});

return () => {
depotDownloaderBuildPromise.then(({ depotDownloader }) => depotDownloader.stop());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export enum DepotDownloaderEventType {
Error = "Error",
Warning = "Warning",
Info = "Info",

}

export interface DepotDownloaderEvent<T = unknown> {
Expand All @@ -27,6 +26,8 @@ export enum DepotDownloaderInfoEvent {
}

export enum DepotDownloaderErrorEvent {
ExeNotFoundWindows = "ExeNotFoundWindows",
ExeNotFoundLinux = "ExeNotFoundLinux",
Password = "Password",
InvalidCredentials = "InvalidCredentials",
NoManifest = "NoManifest",
Expand Down Expand Up @@ -66,4 +67,4 @@ export interface DepotDownloaderArgsOptions {
dir: string,
validate?: boolean,
qr?: boolean,
}
}

0 comments on commit 972794d

Please sign in to comment.