Skip to content

Commit

Permalink
Some logging improvements I apparently had in my branch I guess.
Browse files Browse the repository at this point in the history
  • Loading branch information
PJB3005 committed Jun 11, 2024
1 parent 5368af9 commit 1726bf4
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Robust.Cdn/Services/DataLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ private void Update(CancellationToken cancel)
ArrayPool<byte>.Shared.Return(compressBuffer);
}

_logger.LogDebug("Committing database");

transaction.Commit();

GC.Collect();
Expand All @@ -323,12 +325,15 @@ private List<string> FindNewVersions(SqliteConnection con)
{
using var stmtCheckVersion = con.Handle!.Prepare("SELECT 1 FROM ContentVersion WHERE Version = ?");

var newVersions = new List<string>();
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);

Expand All @@ -345,10 +350,10 @@ private List<string> 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();
}
}

0 comments on commit 1726bf4

Please sign in to comment.