fix(sync): compare stand-ins again after a proxy download that did not finish

The agent recorded the server's update time for a cache of stand-in
thumbnails before the proxy download it queued, so a download that failed
(server restart, network drop) was never queued again once its backoff
ended: the server's sequence may never change again. A comparison that
offers proxies is now recorded only once their download is queued, and
dropped when that download ends other than done.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-12 19:59:53 +00:00
1 parent 827b224ee3
commit 9ca10d96f4
2 files changed
+46 -3

No files matched your search

+11 -3
View File
@@ -237,6 +237,9 @@ public sealed class SyncAgent : IAsyncDisposable
var job = await _sync.Database.Jobs.GetAsync(jobId, cancellationToken).ConfigureAwait(false);
if (job?.State is JobState.Queued or JobState.Running or JobState.Paused) continue;
_proxyJobs.Remove(remoteId);
// A download of stand-ins' proxies that did not finish compares the cache with the manifest again (after its
// backoff when it failed): the server's sequence may never change again to ask for it.
if (job?.State != JobState.Done) _standInsCompared.Remove(remoteId);
if (job?.State == JobState.Failed)
{
var failures = _proxyFailures.GetValueOrDefault(remoteId).Failures + 1;
@@ -255,6 +258,8 @@ public sealed class SyncAgent : IAsyncDisposable
var job = await _sync.EnqueueDownloadAsync(_engine!, Server, link.RemoteId, link.Title, SyncDownloadMode.Proxies, null, JobPriority.Background,
cancellationToken).ConfigureAwait(false);
_proxyJobs[link.RemoteId] = job.Id;
// Compared at this update time once the download that brings what the server offers is queued.
if (!link.ServerHasProxies) _standInsCompared[link.RemoteId] = link.RemoteUpdatedAt;
}
}
@@ -263,7 +268,9 @@ public sealed class SyncAgent : IAsyncDisposable
/// of a cache that did not record its kind) or that has no cached file. The sequence's proxy flag cannot say: it waits
/// for every frame, a missing or damaged one never gets a proxy, and clients and render nodes send the other frames'
/// proxies one by one. The manifest is read once per change of the server's sequence, since a proxy that arrives
/// leaves a new update time (the proxy pass it queues records the sequence's state).
/// leaves a new update time (the proxy pass it queues records the sequence's state). A comparison that offers nothing
/// is recorded here; one that offers proxies is recorded when their download is queued, and dropped when that
/// download does not finish (<see cref="QueueProxiesAsync"/>).
/// </summary>
private async Task<bool> OffersProxiesAsync(SyncLink link, CancellationToken cancellationToken)
{
@@ -280,9 +287,10 @@ public sealed class SyncAgent : IAsyncDisposable
Log.Info(LogCategory, $"The proxies of {link.Title} on {Server} could not be compared: {ex.Message}");
return false;
}
_standInsCompared[link.RemoteId] = link.RemoteUpdatedAt;
var cached = _sync.Proxies.Kinds(Server, link.RemoteId);
return manifest.Frames.Any(f => f.HasProxy && cached.GetValueOrDefault(f.Id) != ProxyCache.Proxy);
if (manifest.Frames.Any(f => f.HasProxy && cached.GetValueOrDefault(f.Id) != ProxyCache.Proxy)) return true;
_standInsCompared[link.RemoteId] = link.RemoteUpdatedAt;
return false;
}
/// <summary>Waits for a wake-up or the delay; false when stopping.</summary>