MISC: Support importing Steam Cloud save file manually (#2583)

This commit is contained in:
catloversg
2026-03-22 12:23:43 +07:00
committed by GitHub
parent a9bb3f6d2f
commit 77cc7874ab
5 changed files with 80 additions and 10 deletions

View File

@@ -6,7 +6,7 @@ const fs = require("fs/promises");
const log = require("electron-log");
const flatten = require("lodash/flatten");
const Store = require("electron-store");
const { isBinaryFormat } = require("./saveDataBinaryFormat");
const { decodeBase64BytesToBytes, isBinaryFormat, isSteamCloudFormat } = require("./saveDataBinaryFormat");
const store = new Store();
const { steamworksClient } = require("./steamworksUtils");
@@ -224,7 +224,7 @@ async function getSteamCloudSaveData() {
async function saveGameToDisk(window, electronGameData) {
const currentFolder = getSaveFolder(window);
let saveFolderSizeBytes = await getFolderSizeInBytes(currentFolder);
const maxFolderSizeBytes = store.get("autosave-quota", 1e8); // 100Mb per playerIndentifier
const maxFolderSizeBytes = store.get("autosave-quota", 1e8); // 100Mb
const remainingSpaceBytes = maxFolderSizeBytes - saveFolderSizeBytes;
log.debug(`Folder Usage: ${saveFolderSizeBytes} bytes`);
log.debug(`Folder Capacity: ${maxFolderSizeBytes} bytes`);
@@ -282,6 +282,9 @@ async function loadFileFromDisk(path) {
if (isBinaryFormat(buffer)) {
// Save file is in the binary format.
content = buffer;
} else if (isSteamCloudFormat(buffer)) {
// Save file is in the Steam Cloud format.
content = decodeBase64BytesToBytes(buffer);
} else {
// Save file is in the base64 format.
content = buffer.toString("utf8");