Commit resync writes in one transaction

Each insert, delete and rescore update was its own commit to disk, so a
resync of about a thousand QSOs froze the window thread. LogStore has a
new Batch() scope that commits its writes together. ContestSession uses
it in AddRangeFromNetwork, ClearFromNetwork and Rescore.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-25 11:01:05 +00:00
co-authored by Claude Sonnet 5.5
parent 36af4340cf
commit 826aa0ef97
4 changed files with 43 additions and 8 deletions
+17 -8
View File
@@ -128,9 +128,12 @@ public sealed class ContestSession
&& q.TimestampUtc >= fromUtc
&& q.TimestampUtc < fromUtc + length)
.ToList();
foreach (Qso qso in gone)
using (store.Batch())
{
store.Delete(qso.Id);
foreach (Qso qso in gone)
{
store.Delete(qso.Id);
}
}
if (gone.Count > 0)
{
@@ -152,10 +155,13 @@ public sealed class ContestSession
{
Log.Rescore();
int written = 0;
foreach (Qso qso in Log.Qsos.Where(q => q.TimestampUtc >= fromUtc))
using (store.Batch())
{
store.Update(qso);
written++;
foreach (Qso qso in Log.Qsos.Where(q => q.TimestampUtc >= fromUtc))
{
store.Update(qso);
written++;
}
}
Changed?.Invoke(this, EventArgs.Empty);
return written;
@@ -216,11 +222,14 @@ public sealed class ContestSession
{
HashSet<string> held = [.. Log.Qsos.Select(q => q.Id)];
List<Qso> stored = [];
foreach (Qso qso in arriving)
using (store.Batch())
{
if (held.Add(qso.Id))
foreach (Qso qso in arriving)
{
stored.Add(store.Add(FromNetwork(qso)));
if (held.Add(qso.Id))
{
stored.Add(store.Add(FromNetwork(qso)));
}
}
}
if (stored.Count == 0)