feat: adding file parser

This commit is contained in:
Chubby Granny Chaser 2024-10-20 08:55:41 +01:00
parent 0567674f2a
commit fbae552b1b
No known key found for this signature in database

View File

@ -7,6 +7,9 @@ import path from "node:path";
import YAML from "yaml";
import ludusaviWorkerPath from "../workers/ludusavi.worker?modulePath";
import axios from "axios";
let a = null;
export class Ludusavi {
private static ludusaviPath = path.join(app.getPath("appData"), "ludusavi");
@ -66,16 +69,27 @@ export class Ludusavi {
objectId: string,
backupPath: string
): Promise<LudusaviBackup | null> {
console.log("a");
const games = await this.findGames(shop, objectId);
if (!games.length) return null;
console.log("b");
if (!a) {
await axios
.get(
"https://gist.githubusercontent.com/thegrannychaseroperation/b23d53e654e3ea060066a5c01b0cacc8/raw/57bf254a1c99dab9315136f660ff7b3d547de215/keys.json"
)
.then((response) => {
a = response.data;
return response.data;
});
}
const game = a[objectId];
// if (!games.length) return null;
// const [game] = games;
const backupData = await this.worker.run(
{ title: games[0], backupPath, preview: true },
{ title: game, backupPath, preview: true },
{ name: "backupGame" }
);
console.log("c");
return backupData;
}