feat(archive): photo delete, tombstones, trash kinds and emptying, library API
Owner review 2, R6: the web panel manages the library without editing it, so the engine and the server must delete single photos safely, keep them out of sync afterwards, and let an administrator restore or finally erase the trash. - Migration 0008: frame_removals (tombstones by sequence and SHA-256, reason, replacement); the sidecar gains "removed" (omitted when empty) and frames a reserved "source"; the indexer writes the tombstones on every sync, so a rebuild keeps them, and drops a hero frame that is gone. - FrameTrash: dry run (busy, frames changed, offline, would empty), delete under the sequence lease with a write-ahead journal that the next writer undoes after a crash, files to trash/photos/<seq>-<time>/originals with a record, sidecar without the frames plus tombstones, index sync clearing analyses, thumbnails and proxies, proxies renamed to follow their frames, follow-up jobs. Restore re-hashes every file, keeps mismatches in the trash, puts the same frame records back and drops their tombstones, or files the photos into a new sequence through the ingest when theirs is gone. - Project positions on vanished photos are translated by photo and wait as pending frames, so they come back with a restore. - Trash entries have a kind (sequence, photos, replaced); emptying is a dry run with a fingerprint and a new EmptyTrash job (18) that erases exactly the planned entries, refuses a stale plan and erases replaced originals only while their replacements still hash right. - Sync honours tombstones: nothing one side deleted is offered back, local files are never deleted, replaced photos count as their replacement; the server answers an upload of a tombstoned SHA-256 as already there. - Server: sequence thumbnail, photo delete, bulk delete/retag/jobs, trash list/restore/empty endpoints with their error messages; a verify of sequences now targets their archive (POST /jobs failed before). - Desktop trash dialog lists photo entries and empties the trash after a typed confirmation through the same job. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 35bb56690a1d69eae57153d036e1409201cd73f7)
This commit is contained in:
1 parent
4b9ba04fe4
commit
51782a3ada
63 files changed
+3303
-60
No files matched your search
@@ -6,6 +6,7 @@ using Chronos.Core.Model;
|
||||
using Chronos.Core.Project;
|
||||
using Chronos.Core.Render;
|
||||
using Chronos.Data.Sync;
|
||||
using Chronos.Protocol;
|
||||
using Chronos.Testing;
|
||||
|
||||
namespace Chronos.Data.Tests.Sync;
|
||||
@@ -116,6 +117,40 @@ public sealed class SyncTransferTests(TestContext context)
|
||||
Assert.Equal((SyncStatus.InSync, 0), (entry.Status, entry.Link!.MissingRemote));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task PhotosOneSideDeletedAreNeitherSentNorFetchedAgain()
|
||||
{
|
||||
await using var f = await SyncFixture.CreateAsync(context);
|
||||
var photos = f.NewPhotos(4);
|
||||
var local = await f.LocalAsync("Comet", photos);
|
||||
// The server holds the first three and deleted the fourth, which this PC still holds.
|
||||
var remote = f.Remote.Add("Comet", photos[..3]);
|
||||
remote.Removed.Add(new RemovedPhotoDto(Sha(photos[3]), null, "deleted", DateTimeOffset.UtcNow));
|
||||
await f.Sync.LinkAsync(f.Server, remote.Id, local.Id, f.Ct);
|
||||
await f.RefreshAsync();
|
||||
Assert.Equal(0, (await f.EntryAsync("Comet")).Link!.MissingRemote);
|
||||
var engine = await f.StartEngineAsync();
|
||||
|
||||
var upload = await f.Sync.EnqueueUploadAsync(engine, f.Server, local);
|
||||
await f.Archive.WaitForAsync(upload.Id, JobState.Done);
|
||||
Assert.Equal(3, remote.Frames.Count);
|
||||
Assert.Count(4, await f.Db.Frames.ListBySequenceAsync(local.Id, cancellationToken: f.Ct));
|
||||
|
||||
// This PC deletes the first photo, which the server still holds: it is not fetched back, and nothing local is deleted.
|
||||
var frames = await f.Db.Frames.ListBySequenceAsync(local.Id, cancellationToken: f.Ct);
|
||||
var sequence = (await f.Db.Sequences.GetAsync(local.Id, f.Ct))!;
|
||||
var plan = await f.Archive.Service.FrameTrash.PlanDeleteAsync(local.Id, [frames[0].Id], sequence.FramesVersion, f.Ct);
|
||||
await f.Archive.Service.FrameTrash.DeleteAsync(plan, null, null, f.Ct);
|
||||
await f.RefreshAsync();
|
||||
var entry = await f.EntryAsync("Comet");
|
||||
Assert.Equal((0, 0), (entry.Link!.MissingRemote, entry.Link.MissingLocal));
|
||||
|
||||
var download = await f.Sync.EnqueueDownloadAsync(engine, f.Server, remote.Id, "Comet", SyncDownloadMode.Originals, null);
|
||||
await f.Archive.WaitForAsync(download.Id, JobState.Done);
|
||||
var kept = await f.Db.Frames.ListBySequenceAsync(local.Id, cancellationToken: f.Ct);
|
||||
Assert.SequenceEqual(photos[1..].Select(Sha), kept.Select(k => k.Sha256!));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AResumedUploadSendsOnlyWhatTheServerLacks()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user