Phase 4b review, codec findings. A Replace makes the converted file the photo, so a conversion must not lose what the original held, and the dry run must promise only what the job will do. - Linear DNG from a conversion is scene-referred: the pixels are stored in linear ProPhoto primaries (colours outside sRGB stay positive) and divided by the power of two that brings their peak under the white level (at most 4 stops), with BaselineExposure giving it back and ColorMatrix1/ForwardMatrix1 describing that space. Highlights a RAW develops above 1 and its wide-gamut colours now read back as written. Exports keep the clipped linear-sRGB DNG. - A conversion reads with the managed decoders first for every format they read natively (RAWs developed at float precision, as on the server) and with WIC only for what they cannot. A RAW only WIC's Raw Image Extension develops (8 bits) is refused for TIFF-16 and linear DNG and planned out as "eight_bit"; JPEG still converts it. Providers say so through IImageDecoderProvider.DevelopsRawAt8Bits. - The original's colour space is kept: a JPEG (APP2) or TIFF (tag 34675) carries its ICC profile, with the values unchanged; a linear DNG gets the values converted through a matrix/TRC profile; a gray profile converts to sRGB. Exif Adobe RGB (uncalibrated + R03) and HEIF nclx P3 get an in-house profile. A space nothing here can keep (CMYK, a lookup-table profile into a DNG, uncalibrated without R03, HDR nclx) is planned out as "color_profile". New in-house ICC parser/writer and header reader for JPEG, PNG, TIFF, HEIF/AVIF and WebP. - The planner asks every file, whatever tier was recorded (unknown before the light analysis, or by another host), with the conversion's decoders, headers only and eight at a time; a RAW the server cannot develop is "convert_on_pc" in the plan instead of failing its sequence. Photos a target cannot hold (a JPEG side above 65535, more samples than one buffer) are planned out as "too_large", and an overflow fails its photo rather than the job. - A photo that fails reads in the job log as one catalog sentence by cause (Archive.Convert.Failed.*), the file named once; the exception's English text goes to the diagnostics log only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 0ca1e91ea09946d7a55f45695ee58e1a0ff5f779)
174 lines
12 KiB
C#
174 lines
12 KiB
C#
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);
|
||
|
||
/// <summary>
|
||
/// <c>POST /api/v1/archive/reorganize</c> (owner review 2, R7; administrators of the archive): new folder, file and title
|
||
/// templates applied to sequences already in the archive, <see cref="SequenceIds"/> or every one with <see cref="All"/>
|
||
/// (exactly one of the two). A null template keeps that part; at least one is given, each valid as the archive settings'
|
||
/// templates are. <see cref="DryRun"/> answers the plan (<see cref="ReorganizePlanDto"/>) and changes nothing; the server
|
||
/// keeps it a few minutes, a refusal too, so the same dry run again (also after one cut off) is answered from it; 503
|
||
/// <c>plan_dropped</c> when the server stopped making it (it took too long, or too many were asked at once). The change
|
||
/// itself sends that plan's <see cref="Fingerprint"/> back and runs as a <c>move</c> job (202): 409 <c>plan_changed</c>
|
||
/// when the index changed since in what the plan reads (the sequences' rows, and which of their photos are hashed, as a
|
||
/// verify does); a change made on disk alone, which the index does not have yet, is found by the job, which then fails and
|
||
/// changes nothing.
|
||
/// </summary>
|
||
public sealed record ReorganizeRequest(IReadOnlyList<Guid>? SequenceIds, bool All, string? FolderTemplate, string? FileTemplate, string? TitleTemplate,
|
||
bool DryRun, string? Fingerprint = null);
|
||
|
||
/// <summary>A file a Reorganize renames: its name before and after, relative to the sequence folder (<c>originals/…</c>).</summary>
|
||
public sealed record ReorganizeFileDto(string From, string To);
|
||
|
||
/// <summary>
|
||
/// Why part of a sequence stays as it is in a Reorganize, as one localised sentence: photos that keep their names,
|
||
/// <see cref="Reason"/> <c>in_place</c> (kept in place outside <c>originals/</c>), <c>unhashed</c> (never verified) or
|
||
/// <c>missing</c>, with how many; or <c>unreadable</c> (0 photos): the sequence's sidecar cannot be read, so the sequence
|
||
/// keeps its folder, title and names, and so does every folder it is inside.
|
||
/// </summary>
|
||
public sealed record ReorganizeBlockedDto(string Reason, int Photos, string Message);
|
||
|
||
/// <summary>
|
||
/// One sequence of a Reorganize plan, in the order the steps apply: its folder and title before and after,
|
||
/// <see cref="Carried"/> when it only moves with a folder it is inside, the frames version its file names were planned at
|
||
/// (0 when none changes), how many photos get a new name with the first of them (<see cref="FileSamples"/>), and what stays
|
||
/// as it is (<see cref="Blocked"/>). A step that changes nothing lists only that.
|
||
/// </summary>
|
||
public sealed record ReorganizeStepDto(Guid SequenceId, string FromFolder, string ToFolder, string? FromTitle, string? ToTitle, bool Carried,
|
||
int FramesVersion, int FileChanges, IReadOnlyList<ReorganizeFileDto> FileSamples, IReadOnlyList<ReorganizeBlockedDto> Blocked);
|
||
|
||
/// <summary>
|
||
/// The dry run of a Reorganize: its steps (those that change nothing list only what stays as it is), the sequences that
|
||
/// change (carried ones included), the photos renamed, the photos that keep their names (a sequence that stays as it is
|
||
/// whole, <c>unreadable</c>, counts none), and the fingerprint the change sends back.
|
||
/// </summary>
|
||
public sealed record ReorganizePlanDto(IReadOnlyList<ReorganizeStepDto> Steps, int Sequences, int Files, int Kept, string Fingerprint);
|
||
|
||
/// <summary>
|
||
/// <c>POST /api/v1/archive/convert</c> (owner review 2, R7; administrators of the archive): the photos of
|
||
/// <see cref="SequenceIds"/>, or of every sequence with <see cref="All"/> (exactly one of the two), converted to
|
||
/// <see cref="Target"/> (<c>jpeg</c>, <c>tiff16</c> or <c>linear-dng</c>, the archival choice) with <see cref="Quality"/> 1–100
|
||
/// for a JPEG (default 95, ignored otherwise). <see cref="Mode"/>, chosen at every run: <c>replace</c> (the converted files
|
||
/// become the frames, the originals go to the archive's trash) or <c>new-sequence</c> (copies in a new sequence, the source
|
||
/// untouched). <see cref="DryRun"/> answers the plan (<see cref="ConvertPlanDto"/>) and changes nothing; the change itself
|
||
/// sends that plan's <see cref="Fingerprint"/> back (409 <c>plan_changed</c> when the archive changed since) and runs as a
|
||
/// <c>convert</c> job (202).
|
||
/// </summary>
|
||
public sealed record ConvertRequest(IReadOnlyList<Guid>? SequenceIds, bool All, string? Target, int? Quality, string? Mode, bool DryRun,
|
||
string? Fingerprint = null);
|
||
|
||
/// <summary>
|
||
/// Photos of a sequence a conversion leaves as they are: <see cref="Reason"/> <c>same_format</c>, <c>convert_on_pc</c> (the
|
||
/// server cannot read them at full resolution: a CR3, a HEIC, a body its RAW decoder does not support), <c>undecodable</c>,
|
||
/// <c>missing</c>, <c>unhashed</c> (never verified), <c>eight_bit</c> (a RAW the host develops at 8 bits only, for a 16-bit
|
||
/// target), <c>color_profile</c> (a colour profile the target can neither keep nor convert to) or <c>too_large</c>, how
|
||
/// many, and the reason as one localised sentence.
|
||
/// </summary>
|
||
public sealed record ConvertSkippedDto(string Reason, int Photos, string Message);
|
||
|
||
/// <summary>Why a whole sequence is not converted now: <see cref="Reason"/> <c>busy</c>, <c>offline</c>, <c>unreadable</c> or <c>frames_changed</c>, as one localised sentence too.</summary>
|
||
public sealed record ConvertBlockedDto(string Reason, string Message);
|
||
|
||
/// <summary>
|
||
/// One sequence of a conversion plan: its title, folder and the frames version it was planned at, the photos converted
|
||
/// with their size now and the estimated size after, the photos left as they are and why, and what blocks the sequence
|
||
/// (it is then not converted).
|
||
/// </summary>
|
||
public sealed record ConvertSequenceDto(Guid SequenceId, string Title, string Folder, int FramesVersion, int Photos, long BytesBefore, long BytesAfter,
|
||
IReadOnlyList<ConvertSkippedDto> Skipped, IReadOnlyList<ConvertBlockedDto> Blocked);
|
||
|
||
/// <summary>
|
||
/// The space a conversion needs on the archive's volume (the estimate × 1.15 plus a 512 MiB reserve; with <c>replace</c> the
|
||
/// originals stay in the trash, so it adds up), what is free there (null when it cannot be measured), whether it is
|
||
/// enough, and the line the dialog shows.
|
||
/// </summary>
|
||
public sealed record ConvertSpaceDto(long Required, long? Free, bool Enough, string Message);
|
||
|
||
/// <summary>
|
||
/// The dry run of a conversion: the target, quality and mode, each sequence asked for in order (<see cref="Steps"/>), the
|
||
/// sequences and photos converted, the photos skipped, the bytes before and the estimate after, the space, and the
|
||
/// fingerprint the change sends back.
|
||
/// </summary>
|
||
public sealed record ConvertPlanDto(string Target, int Quality, string Mode, IReadOnlyList<ConvertSequenceDto> Steps, int Sequences, int Photos, int Skipped,
|
||
long BytesBefore, long BytesAfter, ConvertSpaceDto Space, string Fingerprint);
|