From 1726bf48b6ca09ba3058c4186bdd8321aaae424a Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Tue, 11 Jun 2024 17:07:44 +0200 Subject: [PATCH] Some logging improvements I apparently had in my branch I guess. --- Robust.Cdn/Services/DataLoader.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Robust.Cdn/Services/DataLoader.cs b/Robust.Cdn/Services/DataLoader.cs index 5d1f759..d669cbb 100644 --- a/Robust.Cdn/Services/DataLoader.cs +++ b/Robust.Cdn/Services/DataLoader.cs @@ -314,6 +314,8 @@ private void Update(CancellationToken cancel) ArrayPool.Shared.Return(compressBuffer); } + _logger.LogDebug("Committing database"); + transaction.Commit(); GC.Collect(); @@ -323,12 +325,15 @@ private List FindNewVersions(SqliteConnection con) { using var stmtCheckVersion = con.Handle!.Prepare("SELECT 1 FROM ContentVersion WHERE Version = ?"); - var newVersions = new List(); + var newVersions = new List<(string, DateTime)>(); foreach (var versionDirectory in Directory.EnumerateDirectories(_options.Value.VersionDiskPath)) { + var createdTime = Directory.GetLastWriteTime(versionDirectory); var version = Path.GetFileName(versionDirectory); + _logger.LogTrace("Found version directory: {VersionDir}, write time: {WriteTime}", versionDirectory, createdTime); + stmtCheckVersion.Reset(); stmtCheckVersion.BindString(1, version); @@ -345,10 +350,10 @@ private List FindNewVersions(SqliteConnection con) continue; } - newVersions.Add(version); + newVersions.Add((version, createdTime)); _logger.LogTrace("Found new version: {Version}", version); } - return newVersions; + return newVersions.OrderByDescending(x => x.Item2).Select(x => x.Item1).ToList(); } }