fix(sync): replace cached thumbnails once the server offers their proxies
With Keep proxies offline, the agent refreshed a proxy cache only when the server's sequence had ProxiesBuilt. That flag waits for every frame, and a missing or damaged frame never gets a proxy, so a HEIF sequence with one such frame kept the 320-px thumbnails cached in place of proxies forever, although the server offered the other frames' proxies sent by clients. For such a cache the agent now reads the manifest once per change of the server's update time and queues the background download when a frame is offered as a proxy that the cache holds only a stand-in for (or nothing). The test server's fake serves proxies sent to it, as the real one does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
4 files changed
+74
-3
No files matched your search
@@ -159,6 +159,39 @@ public sealed class SyncAgentTests(TestContext context)
|
||||
Assert.Equal(2, (await DownloadsAsync(f)).Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ThumbnailsStandingInAreReplacedOnceTheServerOffersTheirProxies()
|
||||
{
|
||||
await using var f = await SyncFixture.CreateAsync(context);
|
||||
// The server cannot decode these originals and waits for their proxies; one frame (missing or damaged) never gets
|
||||
// one, so the sequence's proxy flag never comes.
|
||||
var remote = f.Remote.Add("Fog", f.NewPhotos(3), status: SequenceStatus.ThumbsBuilt);
|
||||
remote.Undecodable = true;
|
||||
var engine = await f.StartEngineAsync();
|
||||
await f.RefreshAsync();
|
||||
var first = await f.Sync.EnqueueDownloadAsync(engine, f.Server, remote.Id, "Fog", SyncDownloadMode.Proxies, null);
|
||||
await f.Archive.WaitForAsync(first.Id, JobState.Done);
|
||||
Assert.True(Assert.NotNull(f.Sync.OpenRemote(f.Server, remote.Id)).Files.All(file => new FileInfo(file!).Length == 64), "thumbnails stand in");
|
||||
await using var agent = new SyncAgent(f.Sync, f.Remote, () => new SyncPolicy(KeepProxiesOffline: true), engine, EventsOnly);
|
||||
agent.Start();
|
||||
await WaitAsync(() => agent.Snapshot is not null, "first comparison");
|
||||
await agent.RefreshAsync(f.Ct);
|
||||
Assert.Count(1, await DownloadsAsync(f));
|
||||
|
||||
// Another PC sends the proxies of two frames; the server's proxy pass then records the sequence's state.
|
||||
foreach (var frame in remote.Frames.Take(2)) f.Remote.SentProxies[frame.Id] = frame.Proxy;
|
||||
remote.UpdatedAt = DateTimeOffset.UtcNow.AddSeconds(1);
|
||||
await agent.RefreshAsync(f.Ct);
|
||||
var refresh = Assert.Contains(await DownloadsAsync(f), j => j.Id != first.Id);
|
||||
await f.Archive.WaitForAsync(refresh.Id, JobState.Done);
|
||||
|
||||
var opened = Assert.NotNull(f.Sync.OpenRemote(f.Server, remote.Id));
|
||||
Assert.SequenceEqual([remote.Frames[0].Proxy.Length, remote.Frames[1].Proxy.Length, 64], opened.Files.Select(file => (int)new FileInfo(file!).Length));
|
||||
// The frame still waiting keeps its thumbnail; nothing is queued again until the server's sequence changes.
|
||||
await agent.RefreshAsync(f.Ct);
|
||||
Assert.Count(2, await DownloadsAsync(f));
|
||||
}
|
||||
|
||||
private static async Task<IReadOnlyList<Job>> DownloadsAsync(SyncFixture f) =>
|
||||
(await f.Db.Jobs.ListAsync(null, JobKind.Download, 100, null, f.Ct)).Items;
|
||||
|
||||
|
||||
Reference in new issue
Block a user