fix(archive): erase replaced originals only on the archive's own word
A conversion counted as deleted when no frame of the sidecar held it, no tombstone ended its chain and every frame was hashed. A sidecar rebuilt by adoption meets that after a routine verify although it never knew the conversion, so the originals were erased, the dry run calling them the last copy, while the damaged conversion was still in the folder. A sequence found nowhere and missing from this index counted as gone in the same way, even when the walk had only skipped its folder (photos without a sidecar), and its live conversion was never hashed. A conversion is now deleted only on positive evidence: a Deleted tombstone ending its chain in the sequence's sidecar, the sequence in the trash, or the trash's record of erasing it (.chronos/trash/.erased/<id>.json, written before a deleted sequence's folder goes while a replaced entry of it stays, swept once none does). Anything else keeps the entry, and its job log line says what settles it: verify the sequence (a frame never hashed), scan the archive (a sidecar missing or unreadable), rebuild the index (a row the archive does not bear out), or restore the entry to keep its photos. Also: - a dry run or an emptying walks the archive once for every sequence that moved, and again only when a folder it found no longer holds it; - a download queues the passes a frame swap cleared whatever stops the job (JobContext.EnqueueFollowUpAsync with a token), as a restore does; - the confirmation's detail takes Tab and scrolls from the keyboard when it is longer than its card. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8ea25228eb
commit
5012c3bbd2
12 files changed
+657
-108
No files matched your search
@@ -252,6 +252,51 @@ public sealed class JobEngineTests(TestContext context)
|
||||
Assert.Empty((await db.Jobs.ListAsync(null, JobKind.LightAnalyse)).Items);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A follow-up of work already done (a sync download's frame swapped to another encoding, whose thumbnails it cleared) is
|
||||
/// queued whatever stops its job meanwhile: a cancel arriving right after the work leaves it queued, and it runs.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task AFollowUpQueuedWhateverStopsItsJobOutlivesACancel()
|
||||
{
|
||||
await using var db = await OpenAsync();
|
||||
var target = Guid.CreateVersion7();
|
||||
var started = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var queued = new TaskCompletionSource<Job?>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var download = new CallbackHandler(JobKind.Scan, async c =>
|
||||
{
|
||||
started.TrySetResult();
|
||||
try
|
||||
{
|
||||
await Task.Delay(Timeout.InfiniteTimeSpan, c.Cancellation);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
// The work is done; the cancel came before its follow-up was queued.
|
||||
}
|
||||
try
|
||||
{
|
||||
queued.TrySetResult(await c.EnqueueFollowUpAsync(JobKind.Thumbs, [target], "Roof", null, JobPriority.Background, CancellationToken.None));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
queued.TrySetException(ex);
|
||||
}
|
||||
c.Cancellation.ThrowIfCancellationRequested();
|
||||
});
|
||||
await using var engine = new JobEngine(db, [download, new CountingHandler(JobKind.Thumbs, 1)],
|
||||
new JobEngineOptions { Workers = 1, WorkerId = "t", PollInterval = TimeSpan.FromMilliseconds(50) });
|
||||
await engine.StartAsync();
|
||||
var job = await engine.EnqueueAsync(JobKind.Scan, []);
|
||||
await started.Task.WaitAsync(TimeSpan.FromSeconds(10));
|
||||
|
||||
await engine.CancelAsync(job.Id);
|
||||
|
||||
var followUp = Assert.NotNull(await queued.Task.WaitAsync(TimeSpan.FromSeconds(10)), "queued although its job was cancelled");
|
||||
await WaitForStateAsync(db, job.Id, JobState.Cancelled, TimeSpan.FromSeconds(5));
|
||||
Assert.SequenceEqual([target], (await WaitForStateAsync(db, followUp.Id, JobState.Done, TimeSpan.FromSeconds(10))).TargetIds);
|
||||
}
|
||||
|
||||
/// <summary>Waits until <paramref name="condition"/> holds, failing with <paramref name="what"/> after ten seconds.</summary>
|
||||
private static async Task UntilAsync(Func<bool> condition, string what)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user