ci: fixing release pipeline

This commit is contained in:
Chubby Granny Chaser
2025-10-28 21:37:28 +00:00
parent fc6068d603
commit 6b96c99bb1
11 changed files with 80 additions and 5 deletions

View File

@@ -39,6 +39,12 @@ jobs:
- name: Build with cx_Freeze
run: python python_rpc/setup.py build
- name: Copy OpenSSL DLLs
if: matrix.os == 'windows-2022'
run: |
cp hydra-python-rpc/lib/libcrypto-1_1.dll hydra-python-rpc/lib/libcrypto-1_1-x64.dll
cp hydra-python-rpc/lib/libssl-1_1.dll hydra-python-rpc/lib/libssl-1_1-x64.dll
- name: Build Linux
if: matrix.os == 'ubuntu-latest'
run: |

View File

@@ -430,6 +430,7 @@
"add_download_source": "Add source",
"adding": "Adding…",
"failed_add_download_source": "Failed to add download source. Please try again.",
"download_source_already_exists": "This download source URL already exists.",
"download_count_zero": "No download options",
"download_count_one": "{{countFormatted}} download option",
"download_count_other": "{{countFormatted}} download options",

View File

@@ -416,6 +416,9 @@
"validate_download_source": "Validar",
"remove_download_source": "Remover",
"add_download_source": "Adicionar fonte",
"adding": "Adicionando…",
"failed_add_download_source": "Falha ao adicionar fonte de download. Tente novamente.",
"download_source_already_exists": "Esta URL de fonte de download já existe.",
"download_count_zero": "Sem downloads na lista",
"download_count_one": "{{countFormatted}} download na lista",
"download_count_other": "{{countFormatted}} downloads na lista",

View File

@@ -9,6 +9,13 @@ const addDownloadSource = async (
url: string
) => {
try {
const existingSources = await downloadSourcesSublevel.values().all();
const urlExists = existingSources.some((source) => source.url === url);
if (urlExists) {
throw new Error("Download source with this URL already exists");
}
const downloadSource = await HydraApi.post<DownloadSource>(
"/download-sources",
{
@@ -17,7 +24,7 @@ const addDownloadSource = async (
{ needsAuth: false }
);
if (HydraApi.isLoggedIn()) {
if (HydraApi.isLoggedIn() && HydraApi.hasActiveSubscription()) {
try {
await HydraApi.post("/profile/download-sources", {
urls: [url],

View File

@@ -13,7 +13,7 @@ const removeDownloadSource = async (
if (downloadSourceId) params.set("downloadSourceId", downloadSourceId);
if (HydraApi.isLoggedIn()) {
if (HydraApi.isLoggedIn() && HydraApi.hasActiveSubscription()) {
void HydraApi.delete(`/profile/download-sources?${params.toString()}`);
}

View File

@@ -50,9 +50,14 @@ export const loadState = async () => {
DeckyPlugin.checkAndUpdateIfOutdated();
}
await HydraApi.setupApi().then(() => {
await HydraApi.setupApi().then(async () => {
uploadGamesBatch();
void migrateDownloadSources();
const { syncDownloadSourcesFromApi } = await import(
"./services/user"
);
void syncDownloadSourcesFromApi();
// WSClient.connect();
});

View File

@@ -46,7 +46,7 @@ export class HydraApi {
return this.userAuth.authToken !== "";
}
private static hasActiveSubscription() {
public static hasActiveSubscription() {
const expiresAt = new Date(this.userAuth.subscription?.expiresAt ?? 0);
return expiresAt > new Date();
}
@@ -105,6 +105,9 @@ export class HydraApi {
// WSClient.close();
// WSClient.connect();
const { syncDownloadSourcesFromApi } = await import("./user");
syncDownloadSourcesFromApi();
}
}

View File

@@ -18,3 +18,4 @@ export * from "./library-sync";
export * from "./wine";
export * from "./lock";
export * from "./decky-plugin";
export * from "./user";

View File

@@ -0,0 +1,3 @@
export * from "./get-user-data";
export * from "./sync-download-sources";

View File

@@ -0,0 +1,42 @@
import { HydraApi, logger } from "../";
import { downloadSourcesSublevel } from "@main/level";
import type { DownloadSource } from "@types";
export const syncDownloadSourcesFromApi = async () => {
if (!HydraApi.isLoggedIn() || !HydraApi.hasActiveSubscription()) {
return;
}
try {
const profileSources = await HydraApi.get<DownloadSource[]>(
"/profile/download-sources"
);
const existingSources = await downloadSourcesSublevel.values().all();
const existingUrls = new Set(existingSources.map((source) => source.url));
for (const downloadSource of profileSources) {
if (!existingUrls.has(downloadSource.url)) {
try {
await downloadSourcesSublevel.put(downloadSource.id, {
...downloadSource,
isRemote: true,
createdAt: new Date().toISOString(),
});
logger.log(
`Synced download source from profile: ${downloadSource.url}`
);
} catch (error) {
logger.error(
`Failed to sync download source ${downloadSource.url}:`,
error
);
}
}
}
} catch (error) {
logger.error("Failed to sync download sources from API:", error);
}
};

View File

@@ -57,9 +57,13 @@ export function AddDownloadSourceModal({
onAddDownloadSource();
} catch (error) {
logger.error("Failed to add download source:", error);
const errorMessage = error instanceof Error && error.message.includes("already exists")
? t("download_source_already_exists")
: t("failed_add_download_source");
setError("url", {
type: "server",
message: t("failed_add_download_source"),
message: errorMessage,
});
} finally {
setIsLoading(false);