fix(update): verify and apply the actual latest version

This commit is contained in:
Sucukdeluxe
2026-08-21 07:39:37 +02:00
parent 4cebc6fefd
commit 6efdca6885
10 changed files with 154 additions and 41 deletions
+7 -11
View File
@@ -895,17 +895,13 @@ export class AppController {
this.lastUpdateCheckAt = Date.now();
}
return result;
}
public async installUpdate(onProgress?: (progress: UpdateInstallProgress) => void): Promise<UpdateInstallResult> {
const cacheAgeMs = Date.now() - this.lastUpdateCheckAt;
const cached = this.lastUpdateCheck && !this.lastUpdateCheck.error && cacheAgeMs <= 10 * 60 * 1000
? this.lastUpdateCheck
: undefined;
const result = await runInstallWithResume(
this.manager,
() => installLatestUpdate(this.settings.updateRepo, cached, onProgress)
);
}
public async installUpdate(onProgress?: (progress: UpdateInstallProgress) => void): Promise<UpdateInstallResult> {
const result = await runInstallWithResume(
this.manager,
() => installLatestUpdate(this.settings.updateRepo, undefined, onProgress)
);
if (result.started) {
this.lastUpdateCheck = null;
this.lastUpdateCheckAt = 0;
+24
View File
@@ -0,0 +1,24 @@
import fs from "node:fs";
import path from "node:path";
function normalizedVersion(value: unknown): string {
const version = String(value || "").trim();
return /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(version) ? version : "";
}
export function resolveRuntimeAppVersion(
fallbackVersion: string,
resourcesPath: string = (process as NodeJS.Process & { resourcesPath?: string }).resourcesPath || ""
): string {
if (resourcesPath) {
for (const relativePath of ["app.asar/package.json", "app/package.json"]) {
try {
const payload = JSON.parse(fs.readFileSync(path.join(resourcesPath, ...relativePath.split("/")), "utf8")) as { version?: unknown };
const version = normalizedVersion(payload.version);
if (version) return version;
} catch {
}
}
}
return normalizedVersion(fallbackVersion) || "0.0.0";
}
+4 -3
View File
@@ -1,11 +1,12 @@
import path from "node:path";
import os from "node:os";
import { AppSettings } from "../shared/types";
import { getProviderUsageDayKey } from "../shared/provider-daily-limits";
import packageJson from "../../package.json";
import { getProviderUsageDayKey } from "../shared/provider-daily-limits";
import packageJson from "../../package.json";
import { resolveRuntimeAppVersion } from "./app-version";
export const APP_NAME = "Multi Debrid Downloader";
export const APP_VERSION: string = packageJson.version;
export const APP_VERSION: string = resolveRuntimeAppVersion(packageJson.version);
export const API_BASE_URL = "https://api.real-debrid.com/rest/1.0";
export const DCRYPT_UPLOAD_URL = "https://dcrypt.it/decrypt/upload";