Implement archive format tracking in statistics

This commit is contained in:
2025-09-28 02:08:36 +01:00
parent c137fef65d
commit 6c18da1a38
4 changed files with 31 additions and 6 deletions

View File

@@ -664,4 +664,32 @@ public static class Statistics
AaruLogging.Exception(ex, Localization.Core.Exception_while_trying_to_save_statistics);
}
}
/// <summary>Ads a new archive to statistics</summary>
/// <param name="format">Archive format name</param>
public static void AddArchiveFormat(string format)
{
if(string.IsNullOrWhiteSpace(format)) return;
if(Settings.Settings.Current.Stats is not { MediaStats: true }) return;
using var ctx = AaruContext.Create(Settings.Settings.LocalDbPath);
ctx.Archives.Add(new Archive
{
Name = format,
Synchronized = false,
Count = 1
});
try
{
ctx.SaveChanges();
}
catch(SqliteException ex)
{
AaruLogging.Debug(MODULE_NAME, Localization.Core.Exception_while_trying_to_save_statistics);
AaruLogging.Exception(ex, Localization.Core.Exception_while_trying_to_save_statistics);
}
}
}