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
@@ -67,6 +67,36 @@ public sealed class SyncRulesTests
|
||||
Assert.Equal((1, 0), SyncRules.CompareOriginals([null, null], ["bb"]));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PhotosEitherSideRemovedAreNotOfferedBack()
|
||||
{
|
||||
static FramePhoto Photo(string sha) => new(sha, 100, null);
|
||||
var at = new DateTimeOffset(2026, 10, 27, 10, 0, 0, TimeSpan.Zero);
|
||||
var localId = Guid.CreateVersion7();
|
||||
// The server deleted "cc", which this PC still holds; this PC deleted "dd", which the server still holds.
|
||||
var tombstones = new SyncTombstones([new FrameRemoval(localId, "DD", null, RemovalReason.Deleted, at)],
|
||||
[new RemovedPhotoDto("cc", null, "deleted", at)]);
|
||||
Assert.Equal((0, 0), SyncRules.CompareOriginals([Photo("aa"), Photo("bb"), Photo("cc")], [Photo("aa"), Photo("bb"), Photo("dd")], tombstones));
|
||||
Assert.Equal((1, 1), SyncRules.CompareOriginals([Photo("aa"), Photo("cc")], [Photo("aa"), Photo("dd")], SyncTombstones.None));
|
||||
Assert.True(tombstones.DeletedRemotely("CC"));
|
||||
Assert.True(tombstones.DeletedLocally("dd"));
|
||||
Assert.False(tombstones.DeletedLocally("cc"));
|
||||
|
||||
// A photo replaced by a converted file on either side is the same photo as its replacement, and so is a chain of them.
|
||||
var replaced = new SyncTombstones([], [new RemovedPhotoDto("aa", "a2", "replaced", at), new RemovedPhotoDto("a2", "a3", "replaced", at)]);
|
||||
Assert.Equal("a3", replaced.Canonical("AA"));
|
||||
Assert.Equal((0, 0), SyncRules.CompareOriginals([Photo("aa"), Photo("bb")], [Photo("a3"), Photo("bb")], replaced));
|
||||
Assert.False(replaced.DeletedRemotely("aa"), "a replaced photo is there as its replacement");
|
||||
var replacedHere = new SyncTombstones([new FrameRemoval(localId, "bb", "b2", RemovalReason.Replaced, at)], null);
|
||||
Assert.Equal((0, 0), SyncRules.CompareOriginals([Photo("b2")], [Photo("bb")], replacedHere));
|
||||
// A replacement deleted since: neither the photo nor its replacement is offered back.
|
||||
var gone = new SyncTombstones([], [new RemovedPhotoDto("aa", "a2", "replaced", at), new RemovedPhotoDto("a2", null, "deleted", at)]);
|
||||
Assert.Equal((0, 0), SyncRules.CompareOriginals([Photo("aa")], [], gone));
|
||||
Assert.True(SyncTombstones.None.IsEmpty);
|
||||
Assert.SequenceEqual(["deleted", "replaced"], SyncTombstones.ToDto([new FrameRemoval(localId, "aa", null, RemovalReason.Deleted, at),
|
||||
new FrameRemoval(localId, "bb", "b2", RemovalReason.Replaced, at)]).Select(r => r.Reason));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FramesEitherSideHasNotHashedAreMatchedBySizeAndCaptureTime()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user