feat: adding automatic backup on game close

This commit is contained in:
Chubby Granny Chaser 2024-12-26 00:41:57 +00:00
parent 91b1c349e7
commit c9ae543d3e
No known key found for this signature in database
2 changed files with 15 additions and 2 deletions

View File

@ -40,8 +40,7 @@ const bundleBackup = async (
return tarLocation;
};
const uploadSaveGame = async (
_event: Electron.IpcMainInvokeEvent,
export const createBackup = async (
objectId: string,
shop: GameShop,
downloadOptionTitle: string | null
@ -108,4 +107,13 @@ const uploadSaveGame = async (
});
};
const uploadSaveGame = async (
_event: Electron.IpcMainInvokeEvent,
objectId: string,
shop: GameShop,
downloadOptionTitle: string | null
) => {
return createBackup(objectId, shop, downloadOptionTitle);
};
registerEvent("uploadSaveGame", uploadSaveGame);

View File

@ -7,6 +7,7 @@ import { Game } from "@main/entity";
import axios from "axios";
import { exec } from "child_process";
import { ProcessPayload } from "./download/types";
import { createBackup } from "@main/events/cloud-save/upload-save-game";
const commands = {
findWineDir: `lsof -c wine 2>/dev/null | grep '/drive_c/windows$' | head -n 1 | awk '{for(i=9;i<=NF;i++) printf "%s ", $i; print ""}'`,
@ -269,6 +270,10 @@ const onCloseGame = (game: Game) => {
gamesPlaytime.delete(game.id);
if (game.remoteId) {
// create backup
// todo: check for hydra cloud?
createBackup(game.objectID, game.shop, "");
updateGamePlaytime(
game,
performance.now() - gamePlaytime.lastSyncTick,