From b8426e286b8fd719467ea33ead96cba4f7cd32b1 Mon Sep 17 00:00:00 2001 From: zontreck Date: Mon, 1 Jul 2024 23:24:06 -0700 Subject: [PATCH] Start setting up the snapshots feature --- bin/server.dart | 1 + lib/structs/settings.dart | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/bin/server.dart b/bin/server.dart index 92d2231..71dbabb 100644 --- a/bin/server.dart +++ b/bin/server.dart @@ -49,6 +49,7 @@ void main() async { await settings.createModFolderIfNotExists(); await settings.createServerModFolderIfNotExists(); await settings.createModJailFolderIfNotExists(); + await settings.createBackupsFolderIfNotExists(); await settings.writeOutModListFile(); print("Finished checking for game server updates..."); diff --git a/lib/structs/settings.dart b/lib/structs/settings.dart index 8c6d8c4..377bb0e 100644 --- a/lib/structs/settings.dart +++ b/lib/structs/settings.dart @@ -162,6 +162,21 @@ class Settings { return PathHelper(pth: base_path).resolve("mods.jail").build(); } + String getWorldSnapshots() { + return PathHelper(pth: base_path).resolve("backups").build(); + } + + String getWorldGameDB() { + var path = PathHelper(pth: getServerPath()).resolve("ConanSandbox").resolve("Saved"); + var pth2 = path.resolve("game.db"); + if(pth2.exists()) return pth2.build(); + var pth1 = path.resolve("dlc_siptah.db"); + if(pth1.exists()) return pth1.build(); + + + return pth2.build(); // Fallback to game.db + } + Future createModFolderIfNotExists() async { if (Directory(getModPath()).existsSync()) { return; @@ -178,6 +193,14 @@ class Settings { } } + Future createBackupsFolderIfNotExists() async { + if(Directory(getWorldSnapshots()).existsSync()) { + return; + }else { + await Directory(getWorldSnapshots()).create(recursive: true); + } + } + bool serverInstalled() { return File( "${getServerPath()}${Platform.pathSeparator}ConanSandboxServer.exe")