feat: owner review 2 phase 3: Library on the web panel, photo trash and web upload (#11)
CI / Build and test (push) Successful in 7m25s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 10s
CI / PostgreSQL 16 integration (push) Successful in 5m20s
CI / PostgreSQL 17 integration (push) Successful in 5m22s
CI / Docker image (push) Successful in 50s
Release / Build, test and publish (push) Successful in 12m1s
Release / Server image (push) Successful in 1m26s

- Web panel Library: browse, view, delete sequences and photos, mass operations (analyse, proxies, thumbnails, verify, retag, delete, CSV). It never edits the video.
- Photo trash with tombstones (migration 0008): crash-safe delete and restore, hash-checked restore with reasons, and emptying only by an explicit fingerprinted job. Sync and uploads keep deleted photos deleted; an explicit "Upload again" brings one back.
- Upload from the web panel: in-house SHA-256 in a worker with a fail-closed self-test, capture time from EXIF, chunked, resumable; no folders.
- Desktop trash dialog with photo entries and Empty.
- Admin files are revalidated (no-cache + ETag).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #11.
This commit is contained in:
Alby96andClaude Opus 5.5 authored and Alby96 committed 2026-10-27 15:08:39 +01:00
1 parent af9eeaab9b
commit 9aa818ed47
283 files changed
+24922 -293

No files matched your search

+12 -2
View File
@@ -165,7 +165,9 @@ public sealed class ChronosClient : IDisposable
/// <summary>
/// Uploads one file with resumable, idempotent chunks; the server verifies the SHA-256 before committing it
/// (BRIEF §14.4). Returns the committed frame id. Transient failures retry with exponential backoff.
/// (BRIEF §14.4). Returns the committed frame id; null when the server holds the photo without a frame to name: it was
/// deleted from the target sequence, before the upload or while it was on its way (owner review 2, R6). Transient
/// failures retry with exponential backoff.
/// </summary>
public async Task<CompleteUploadResponse?> UploadFileAsync(
string path,
@@ -189,7 +191,15 @@ public sealed class ChronosClient : IDisposable
var uploadId = start.UploadId ?? throw new InvalidOperationException("Server returned no upload id.");
await SendChunksAsync(path, info.Length, uploadId, start.ChunkSize, start.Received, progress, ct).ConfigureAwait(false);
return await RetryAsync(() => SendAsync<CompleteUploadResponse>(HttpMethod.Post, $"api/v1/uploads/{uploadId}/complete", ProtocolJson.Default.CompleteUploadResponse, ct), ct).ConfigureAwait(false);
try
{
return await RetryAsync(() => SendAsync<CompleteUploadResponse>(HttpMethod.Post, $"api/v1/uploads/{uploadId}/complete", ProtocolJson.Default.CompleteUploadResponse, ct), ct)
.ConfigureAwait(false);
}
catch (ChronosApiException ex) when (ex is { Status: HttpStatusCode.Conflict, Error.Code: UploadErrors.PhotoRemoved })
{
return null;
}
}
/// <summary>
+6 -1
View File
@@ -9,6 +9,10 @@ public sealed record ApiError(string Code, string Message, string? Details = nul
public sealed record ServerLimits(long MaxUploadBytes, int ChunkSizeBytes, int PasswordMinLength = 10);
/// <summary><c>GET /api/v1/server/info</c>.</summary>
/// <param name="Extensions">
/// File extensions the archive files as photos (lower case, no dot): the admin panel's upload dialog offers and sends only
/// these (owner review 2, R3). Null from servers that do not announce them.
/// </param>
public sealed record ServerInfo(
string Name,
string Version,
@@ -16,7 +20,8 @@ public sealed record ServerInfo(
IReadOnlyList<string> Capabilities,
string? TlsFingerprint,
IReadOnlyList<string> Formats,
ServerLimits Limits);
ServerLimits Limits,
IReadOnlyList<string>? Extensions = null);
/// <summary><c>GET /health</c>.</summary>
public sealed record HealthStatus(string Status, string Version, IReadOnlyDictionary<string, string> Checks);
+83
View File
@@ -0,0 +1,83 @@
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 photos kept in the trash: their names
/// (<see cref="Kept"/>), why each stayed (<see cref="KeptReasons"/>, in the same order: <c>mismatch</c>, its files no
/// longer match their record; <c>not_moved</c>, they could not be moved back; <c>in_sequence</c>, the sequence holds it
/// already; <c>no_file</c>, its original was missing when it was deleted) and one sentence per reason in the request's
/// language (<see cref="Message"/>; null when none stayed).
/// </summary>
public sealed record TrashRestoreDto(string Name, string Kind, Guid SequenceId, int Photos, IReadOnlyList<string> Kept, bool NewSequence,
IReadOnlyList<string>? KeptReasons = null, string? Message = null);
/// <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);
/// <summary>
/// A value a Library filter offers: <see cref="Value"/> as <c>GET /api/v1/sequences</c> takes it (<c>year</c>, <c>camera</c>,
/// <c>tag</c>), the sequences that have it, and the label a menu shows when it differs (a camera model with its make).
/// </summary>
public sealed record FacetDto(string Value, int Sequences, string? Label = null);
/// <summary>
/// <c>GET /api/v1/sequences/facets</c> (owner review 2, R6): the years of first capture (newest first), camera models (most
/// sequences first) and tags in use (by name) of the archive's sequences, for the admin panel's Library filters.
/// </summary>
public sealed record LibraryFacetsDto(IReadOnlyList<FacetDto> Years, IReadOnlyList<FacetDto> Cameras, IReadOnlyList<FacetDto> Tags);
+14
View File
@@ -73,4 +73,18 @@ 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))]
[JsonSerializable(typeof(LibraryFacetsDto))]
public sealed partial class ProtocolJson : JsonSerializerContext;
+12 -1
View File
@@ -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>
+16 -2
View File
@@ -2,12 +2,26 @@ namespace Chronos.Protocol;
/// <summary>
/// <c>POST /api/v1/uploads</c> (BRIEF §14.4). The client hashes the file first; when the server already holds that
/// SHA-256 it answers 200 with <see cref="StartUploadResponse.AlreadyExists"/> and no upload is needed.
/// SHA-256 it answers 200 with <see cref="StartUploadResponse.AlreadyExists"/> and no upload is needed. A photo deleted
/// from the target sequence is answered the same way, without a frame (owner review 2, R6), unless <see cref="Restore"/>
/// asks to file it there again: only an explicit user action sends it (the admin panel's "Upload again"), never sync or a
/// watch folder, and the completion repeats it (<c>complete?restore=true</c>). Filing it drops the photo's tombstone.
/// </summary>
public sealed record StartUploadRequest(Guid? SequenceId, string FileName, long Size, string Sha256, DateTime? CapturedAt, string? SessionKey);
public sealed record StartUploadRequest(Guid? SequenceId, string FileName, long Size, string Sha256, DateTime? CapturedAt, string? SessionKey,
bool Restore = false);
public sealed record StartUploadResponse(Guid? UploadId, int ChunkSize, IReadOnlyList<int> Received, bool AlreadyExists, Guid? FrameId);
/// <summary>Error codes of the frame upload calls that clients act on.</summary>
public static class UploadErrors
{
/// <summary>
/// 409 from <c>POST /api/v1/uploads/{id}/complete</c>: the photo was deleted from the target sequence while it was on its
/// way and the completion did not ask to restore it, so it was not filed and the upload is cancelled (owner review 2, R6).
/// </summary>
public const string PhotoRemoved = "photo_removed";
}
/// <summary><c>PUT /api/v1/uploads/{id}/chunks/{n}</c> response.</summary>
public sealed record ChunkReceived(int Index, IReadOnlyList<int> Received);