From 4ecb64e1be7dede7eee6c44ff004a65759413642 Mon Sep 17 00:00:00 2001 From: 13xforever Date: Sat, 5 Jul 2025 22:16:00 +0500 Subject: [PATCH] unify some config params, and move datfile location to app data --- CompatBot/Config.cs | 12 ++++++++++-- CompatBot/Ocr/Backend/BackendBase.cs | 7 +------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CompatBot/Config.cs b/CompatBot/Config.cs index 3fdc0e91..f52bd1c2 100644 --- a/CompatBot/Config.cs +++ b/CompatBot/Config.cs @@ -87,7 +87,14 @@ internal static class Config public static string PreferredFontFamily => config.GetValue(nameof(PreferredFontFamily), ""); public static string LogPath => config.GetValue(nameof(LogPath), "./logs/"); // paths are relative to the working directory public static string IrdCachePath => config.GetValue(nameof(IrdCachePath), "./ird/"); - public static string RedumpDatfileCachePath => config.GetValue(nameof(RedumpDatfileCachePath), "./datfile/"); + public static string BotAppDataFolder => config.GetValue( + nameof(BotAppDataFolder), + Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), + "compat-bot" + ) + ); + public static string RedumpDatfileCachePath => Path.Combine(BotAppDataFolder, "compat-bot", "datfile"); public static string RenameNameSuffix => config.GetValue(nameof(RenameNameSuffix), " (Rule 7)"); public static string OcrBackend => config.GetValue(nameof(OcrBackend), "auto"); // possible values: auto, tesseract, florence2, azure @@ -248,6 +255,7 @@ internal static class Config var fileTarget = new FileTarget("logfile") { FileName = CurrentLogPath, ArchiveEvery = FileArchivePeriod.Day, + MaxArchiveDays = 30, //ArchiveSuffixFormat = ".{1:yyyyMMdd}.{0:00}", ArchiveNumbering = ArchiveNumberingMode.DateAndSequence, ConcurrentWrites = false, @@ -334,4 +342,4 @@ internal static class Config var branch = await GitRunner.Exec("rev-parse --abbrev-ref HEAD", cancellationToken); GitRevision = $"{commit} on {branch}"; } -} \ No newline at end of file +} diff --git a/CompatBot/Ocr/Backend/BackendBase.cs b/CompatBot/Ocr/Backend/BackendBase.cs index 0f48d514..c27a40ad 100644 --- a/CompatBot/Ocr/Backend/BackendBase.cs +++ b/CompatBot/Ocr/Backend/BackendBase.cs @@ -29,10 +29,5 @@ public abstract class BackendBase: IOcrBackend, IDisposable public virtual void Dispose() => HttpClient.Dispose(); - protected string ModelCachePath => Path.Combine( - Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), - "discord-bot", - "ocr-models", - Name.ToLowerInvariant() - ); + protected string ModelCachePath => Path.Combine(Config.BotAppDataFolder, "ocr-models", Name.ToLowerInvariant()); } \ No newline at end of file