feat: improving cloud sync manual mapping

This commit is contained in:
Chubby Granny Chaser
2024-10-22 13:34:34 +01:00
parent 7de6e96f63
commit bfcf8178d8
15 changed files with 164 additions and 132 deletions

View File

@@ -1,29 +1,10 @@
import type { GameShop, LudusaviBackup, LudusaviFindResult } from "@types";
import type { LudusaviBackup } from "@types";
import cp from "node:child_process";
import { workerData } from "node:worker_threads";
const { binaryPath } = workerData;
export const findGames = ({
shop,
objectId,
}: {
shop: GameShop;
objectId: string;
}) => {
const args = ["find", "--api"];
if (shop === "steam") {
args.push("--steam-id", objectId);
}
const result = cp.execFileSync(binaryPath, args);
const games = JSON.parse(result.toString("utf-8")) as LudusaviFindResult;
return Object.keys(games.games);
};
export const backupGame = ({
title,
backupPath,
@@ -35,7 +16,7 @@ export const backupGame = ({
preview?: boolean;
winePrefix?: string;
}) => {
const args = ["backup", `"${title}"`, "--api", "--force"];
const args = ["backup", title, "--api", "--force"];
if (preview) args.push("--preview");
if (backupPath) args.push("--path", backupPath);