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
@@ -0,0 +1,67 @@
|
||||
namespace Chronos.Protocol;
|
||||
|
||||
/// <summary>
|
||||
/// <c>POST /api/v1/sequences/{id}/frames/delete</c> (owner review 2, R6): the photos to move into the archive's trash.
|
||||
/// <see cref="ExpectedFramesVersion"/> is the frames version the ids were read at: a sequence whose frames changed since
|
||||
/// answers 409 <c>frames_conflict</c>. <see cref="DryRun"/> only reports what would happen.
|
||||
/// </summary>
|
||||
public sealed record FrameDeleteRequest(IReadOnlyList<Guid> FrameIds, int? ExpectedFramesVersion, bool DryRun);
|
||||
|
||||
/// <summary>
|
||||
/// What a photo deletion does (dry run) or did: the photos and bytes that go, the sequence's frames version (as it is on a
|
||||
/// dry run, after the deletion otherwise) and the trash entry made (null on a dry run).
|
||||
/// </summary>
|
||||
public sealed record FrameDeleteResultDto(Guid SequenceId, int Photos, long Bytes, int FramesVersion, int FrameCount, string? TrashEntry, bool DryRun);
|
||||
|
||||
/// <summary>
|
||||
/// An entry of the archive's trash (<c>GET /api/v1/archive/trash</c>): a deleted sequence (<see cref="Kind"/> <c>sequence</c>)
|
||||
/// or photos deleted from one (<c>photos</c>; <c>replaced</c> for originals a conversion replaced). <see cref="Name"/>
|
||||
/// identifies it in restore and empty requests.
|
||||
/// </summary>
|
||||
public sealed record TrashEntryDto(string Name, string Kind, Guid SequenceId, string Title, string Folder, int Photos, int Files, long Bytes,
|
||||
string? DeletedBy, DateTimeOffset DeletedAt);
|
||||
|
||||
/// <summary><c>GET /api/v1/archive/trash</c>: the entries, newest first, and their total size.</summary>
|
||||
public sealed record TrashListDto(IReadOnlyList<TrashEntryDto> Entries, long Bytes);
|
||||
|
||||
/// <summary>
|
||||
/// <c>POST /api/v1/archive/trash/{name}/restore</c>: the sequence the entry went back into (a new one when the photos'
|
||||
/// sequence is gone: <see cref="NewSequence"/>), how many photos came back, and the files kept in the trash because they
|
||||
/// no longer match their record.
|
||||
/// </summary>
|
||||
public sealed record TrashRestoreDto(string Name, string Kind, Guid SequenceId, int Photos, IReadOnlyList<string> Kept, bool NewSequence);
|
||||
|
||||
/// <summary>
|
||||
/// <c>POST /api/v1/archive/trash/empty</c>: erase the entries <see cref="Names"/> (null: every entry). A dry run answers the
|
||||
/// plan with its <see cref="TrashEmptyPlanDto.Fingerprint"/>; the erase itself must send that fingerprint back (409
|
||||
/// <c>trash_changed</c> when the trash changed since) and runs as an <c>empty-trash</c> job (202).
|
||||
/// </summary>
|
||||
public sealed record TrashEmptyRequest(IReadOnlyList<string>? Names, bool DryRun, string? Fingerprint);
|
||||
|
||||
/// <summary>The dry run of emptying the trash: the entries measured on disk, their totals, the fingerprint, and names not in the trash.</summary>
|
||||
public sealed record TrashEmptyPlanDto(IReadOnlyList<TrashEntryDto> Entries, int Photos, int Files, long Bytes, string Fingerprint, IReadOnlyList<string> Unknown);
|
||||
|
||||
/// <summary><c>POST /api/v1/sequences/bulk/delete</c>: move these sequences into the trash (or, with <see cref="DryRun"/>, say what would).</summary>
|
||||
public sealed record BulkDeleteRequest(IReadOnlyList<Guid> Ids, bool DryRun);
|
||||
|
||||
/// <summary><c>POST /api/v1/sequences/bulk/retag</c>: add and remove tags on these sequences (the same edit as a PATCH of their tags).</summary>
|
||||
public sealed record BulkRetagRequest(IReadOnlyList<Guid> Ids, IReadOnlyList<string>? Add, IReadOnlyList<string>? Remove);
|
||||
|
||||
/// <summary>
|
||||
/// <c>POST /api/v1/sequences/bulk/jobs</c>: queue one job of <see cref="Kind"/> (<c>analyse</c>, <c>deep</c>, <c>proxies</c>,
|
||||
/// <c>thumbnails</c>, <c>verify</c>) over these sequences.
|
||||
/// </summary>
|
||||
public sealed record BulkJobsRequest(IReadOnlyList<Guid> Ids, string Kind);
|
||||
|
||||
/// <summary>
|
||||
/// One sequence of a bulk operation: <see cref="Outcome"/> <c>ok</c>, or <c>skipped</c> with the error code that says why
|
||||
/// (<see cref="Reason"/>, e.g. <c>not_found</c>, <c>forbidden</c>, <c>sequence_busy</c>) and its localised sentence.
|
||||
/// </summary>
|
||||
/// <param name="TrashFolder">For a delete: where the folder goes (or went) in the trash; null when it has no folder.</param>
|
||||
public sealed record BulkItemResult(Guid Id, string Outcome, string? Reason = null, string? Message = null, string? TrashFolder = null);
|
||||
|
||||
/// <summary>
|
||||
/// The result of a bulk operation: one item per id asked for, the counts, the photos and bytes a delete moves (or moved),
|
||||
/// and the job a bulk job request queued (null when nothing was queued).
|
||||
/// </summary>
|
||||
public sealed record BulkResultDto(IReadOnlyList<BulkItemResult> Items, int Ok, int Skipped, bool DryRun, int Photos = 0, long Bytes = 0, JobDto? Job = null);
|
||||
@@ -73,4 +73,17 @@ namespace Chronos.Protocol;
|
||||
[JsonSerializable(typeof(CreateScheduleRequest))]
|
||||
[JsonSerializable(typeof(UpdateScheduleRequest))]
|
||||
[JsonSerializable(typeof(ScheduleRunDto))]
|
||||
[JsonSerializable(typeof(RemovedPhotoDto))]
|
||||
[JsonSerializable(typeof(FrameDeleteRequest))]
|
||||
[JsonSerializable(typeof(FrameDeleteResultDto))]
|
||||
[JsonSerializable(typeof(TrashEntryDto))]
|
||||
[JsonSerializable(typeof(TrashListDto))]
|
||||
[JsonSerializable(typeof(TrashRestoreDto))]
|
||||
[JsonSerializable(typeof(TrashEmptyRequest))]
|
||||
[JsonSerializable(typeof(TrashEmptyPlanDto))]
|
||||
[JsonSerializable(typeof(BulkDeleteRequest))]
|
||||
[JsonSerializable(typeof(BulkRetagRequest))]
|
||||
[JsonSerializable(typeof(BulkJobsRequest))]
|
||||
[JsonSerializable(typeof(BulkItemResult))]
|
||||
[JsonSerializable(typeof(BulkResultDto))]
|
||||
public sealed partial class ProtocolJson : JsonSerializerContext;
|
||||
@@ -75,6 +75,10 @@ public sealed record FrameDto(
|
||||
|
||||
/// <summary><c>GET /api/v1/sequences/{id}/manifest</c>: what a client needs to diff a sequence (BRIEF §14.5).</summary>
|
||||
/// <param name="Proxies">How to make the proxies the server asks for (<see cref="ManifestFrame.WantsProxy"/>); null when it makes none.</param>
|
||||
/// <param name="Removed">
|
||||
/// Tombstones of the photos removed from the sequence (owner review 2, R6): a client never offers them back, and counts a
|
||||
/// replaced photo and its replacement as one; null from servers before owner review 2 and when there are none.
|
||||
/// </param>
|
||||
public sealed record SequenceManifest(
|
||||
Guid SequenceId,
|
||||
int FramesVersion,
|
||||
@@ -83,7 +87,14 @@ public sealed record SequenceManifest(
|
||||
IReadOnlyList<string> Tags,
|
||||
IReadOnlyList<ManifestFrame> Frames,
|
||||
IReadOnlyList<RenderDto> Renders,
|
||||
ProxySpec? Proxies = null);
|
||||
ProxySpec? Proxies = null,
|
||||
IReadOnlyList<RemovedPhotoDto>? Removed = null);
|
||||
|
||||
/// <summary>
|
||||
/// A photo removed from a sequence (owner review 2, R6): its lower-case hex SHA-256, the replacement's when a conversion
|
||||
/// replaced it, why (<c>deleted</c>, <c>replaced</c>) and when.
|
||||
/// </summary>
|
||||
public sealed record RemovedPhotoDto(string Sha256, string? Replacement, string Reason, DateTimeOffset At);
|
||||
|
||||
/// <summary>One frame of a manifest: its content, whether the server has a proxy and thumbnail of it, and its flags.</summary>
|
||||
/// <param name="Sha256">Lower-case hex SHA-256; empty while the server has not hashed it (a folder adopted and not verified yet).</param>
|
||||
|
||||
Reference in new issue
Block a user