From 6c4d989fcd382e36620c7f46b10e4adc5a1a8199 Mon Sep 17 00:00:00 2001 From: Frog Date: Fri, 17 Jul 2026 00:46:34 -0700 Subject: [PATCH] Relocate Cache Related Data - Renames choices.json to saved-game-choices.json - Relocates all cache JSON files to the C:\ProgramData\CreamInstaller\Cache folder --- CreamInstaller/Utility/ProgramData.cs | 32 ++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/CreamInstaller/Utility/ProgramData.cs b/CreamInstaller/Utility/ProgramData.cs index 499a083..d017eee 100644 --- a/CreamInstaller/Utility/ProgramData.cs +++ b/CreamInstaller/Utility/ProgramData.cs @@ -72,9 +72,12 @@ internal static class ProgramData internal static readonly string CooldownPath = CachePath + @"\cooldown"; private static readonly string OldProgramChoicesPath = DirectoryPath + @"\choices.txt"; - private static readonly string ProgramChoicesPath = DirectoryPath + @"\choices.json"; - private static readonly string KoaloaderProxyChoicesPath = DirectoryPath + @"\proxies.json"; - private static readonly string ExtraProtectionChoicesPath = DirectoryPath + @"\extraprotection.json"; + private static readonly string OldProgramChoicesJsonPath = DirectoryPath + @"\choices.json"; + private static readonly string OldKoaloaderProxyChoicesPath = DirectoryPath + @"\proxies.json"; + private static readonly string OldExtraProtectionChoicesPath = DirectoryPath + @"\extraprotection.json"; + private static readonly string ProgramChoicesPath = CachePath + @"\saved-game-choices.json"; + private static readonly string KoaloaderProxyChoicesPath = CachePath + @"\proxies.json"; + private static readonly string ExtraProtectionChoicesPath = CachePath + @"\extraprotection.json"; private static readonly string InstalledGamesPath = CachePath + @"\installed.json"; internal static readonly string ScanLogPath = Path.Combine(DirectoryPath, "game-scan.log"); @@ -234,10 +237,33 @@ internal static event Action OnLog; } CooldownPath.CreateDirectory(); + CachePath.CreateDirectory(); if (OldProgramChoicesPath.FileExists()) OldProgramChoicesPath.DeleteFile(); + MigrateOldPath(OldProgramChoicesJsonPath, ProgramChoicesPath); + MigrateOldPath(OldKoaloaderProxyChoicesPath, KoaloaderProxyChoicesPath); + MigrateOldPath(OldExtraProtectionChoicesPath, ExtraProtectionChoicesPath); }); + private static void MigrateOldPath(string oldPath, string newPath) + { + if (!oldPath.FileExists()) + return; + if (newPath.FileExists()) + return; + try + { + string content = oldPath.ReadFile(); + newPath.WriteFile(content); + oldPath.DeleteFile(); + Log.Info($"Migrated {Path.GetFileName(oldPath)} -> {Path.GetFileName(newPath)}"); + } + catch + { + // ignored; migration failure must not crash the application + } + } + private static readonly System.Collections.Concurrent.ConcurrentDictionary CooldownCache = new(); internal static bool CheckCooldown(string identifier, int cooldown)