From d232cf84915f301496712eed38dbef4598871854 Mon Sep 17 00:00:00 2001 From: Mario Steele Date: Sun, 7 Jul 2024 18:19:27 -0500 Subject: [PATCH] Added Backup Database File Added Get Backup Database File path, so that we can properly backup the database / restore the database, incase of corruption. --- libs/util/Util.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/libs/util/Util.cs b/libs/util/Util.cs index a83d8e8..00185f1 100644 --- a/libs/util/Util.cs +++ b/libs/util/Util.cs @@ -89,9 +89,25 @@ public static string GetDatabaseFile() { var path = GetUserFolder("central_store.json"); if (!OS.GetExecutablePath().GetFile().StartsWith("GodotManager")) - { path = GetUserFolder("central_store_devel.json"); + if (OS.GetExecutablePath().GetFile().StartsWith("GodotManager")) + { + if (SFile.Exists(OS.GetExecutablePath().GetBaseDir().Join("._sc_")) || + SFile.Exists(OS.GetExecutablePath().GetBaseDir().Join("_sc_"))) + { + if (!Dir.Exists(path.GetBaseDir())) + Dir.CreateDirectory(path.GetBaseDir()); + } } + + return path; + } + + public static string GetBackupDatabaseFile() + { + var path = GetUserFolder("central_store.bak"); + if (!OS.GetExecutablePath().GetFile().StartsWith("GodotManager")) + path = GetUserFolder("central_store_devel.bak"); if (OS.GetExecutablePath().GetFile().StartsWith("GodotManager")) { if (SFile.Exists(OS.GetExecutablePath().GetBaseDir().Join("._sc_")) ||