Relocate Cache Related Data

- Renames choices.json to saved-game-choices.json
- Relocates all cache JSON files to the C:\ProgramData\CreamInstaller\Cache folder
This commit is contained in:
Frog
2026-07-17 00:46:34 -07:00
parent 92379aebfd
commit 6c4d989fcd
+29 -3
View File
@@ -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<LogEventArgs> 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<string, DateTime> CooldownCache = new();
internal static bool CheckCooldown(string identifier, int cooldown)