E3: conversione della libreria in sottofondo con righe sempre vere
La libreria può ora tenere accanto a ogni originale una copia nel formato scelto, preparata in sottofondo senza mai sostituire o cancellare l'originale. - LongWorkGate ha un permesso di sottofondo che il lavoro in primo piano (importazione, copie, ricostruzione) interrompe; il salvataggio in corso si aspetta al più CommitWait. - La coda e il lavoratore: nuovi file accodati all'arrivo, quelli già in libreria solo su richiesta, pausa, nuovo tentativo, attesa durante una sessione del motore o con poco spazio, nomi liberi e adozione di un file identico già presente. - Le righe di media_conversion restano vere in ogni via: eliminazione (Ricorda e Consenti il ritorno, con RemoveWithConversionsAsync per il vincolo RESTRICT), perdente del ripasso dei doppioni, file cambiato (superate e riaccodate), ricostruzione (conta e riconosce i convertiti, accoda solo Pending), importazione (una copia convertita o un fotogramma non rientra come file nuovo). - FebeApp avvia il lavoratore con InBackground; la demo mai. _febe.jsonl non cambia. La prova RecordsCannotBeDeletedFromUnderTheirCopies usa ora una riga Converted: RemoveAsync toglie da sé le righe senza file, e il vincolo si verifica sia in SQL sia attraverso il magazzino. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b746aff45d
commit
724c5bda6f
25 files changed
+2621
-38
No files matched your search
@@ -58,11 +58,28 @@ public interface IEntryStore
|
||||
/// «Eliminato»: the entry stays without files so it is not downloaded again (spec §4.6). Its files become
|
||||
/// <see cref="MediaState.Deleted"/> and lose their path and perceptual hash; SHA-256 and size are kept. Deleting files on disk is the caller's job.
|
||||
/// </summary>
|
||||
Task MarkDeletedAsync(long entryId, DateTimeOffset at, CancellationToken ct = default);
|
||||
Task MarkDeletedAsync(long entryId, DateTimeOffset at, CancellationToken ct = default) => MarkDeletedAsync(entryId, at, [], ct);
|
||||
|
||||
/// <summary>«Eliminalo e lascia che torni»: removes the record (files records and highlight links by cascade).</summary>
|
||||
/// <summary>
|
||||
/// As <see cref="MarkDeletedAsync(long, DateTimeOffset, CancellationToken)"/>, and in the same transaction the
|
||||
/// conversions for the library of its files: the queue and the failures (Pending, Failed) go, and the rows of
|
||||
/// <paramref name="removedConversionIds"/> (whose converted file goes or is gone) become «Tolto». Other converted rows stay.
|
||||
/// </summary>
|
||||
Task MarkDeletedAsync(long entryId, DateTimeOffset at, IReadOnlyCollection<long> removedConversionIds, CancellationToken ct = default);
|
||||
|
||||
/// <summary>
|
||||
/// «Eliminalo e lascia che torni»: removes the record (files records and highlight links by cascade). Conversions
|
||||
/// without a file left (Pending, Failed, Removed) go with it; a Converted or Superseded one makes it fail with
|
||||
/// <see cref="InvalidOperationException"/> (its file would be forgotten): use <see cref="RemoveWithConversionsAsync"/>.
|
||||
/// </summary>
|
||||
Task RemoveAsync(long entryId, CancellationToken ct = default);
|
||||
|
||||
/// <summary>
|
||||
/// «Eliminalo e lascia che torni» from «Elimina dalla libreria»: removes the record and every conversion of its files
|
||||
/// in one transaction, and returns the conversions removed (their converted files are the caller's to delete).
|
||||
/// </summary>
|
||||
Task<IReadOnlyList<MediaConversion>> RemoveWithConversionsAsync(long entryId, CancellationToken ct = default);
|
||||
|
||||
/// <summary>Entries of an account ordered by publication time, newest first (account tabs, collection pipeline).</summary>
|
||||
Task<IReadOnlyList<Entry>> ListByAccountAsync(long accountId, EntryListOptions? options = null, CancellationToken ct = default);
|
||||
|
||||
|
||||
@@ -198,6 +198,13 @@ public interface IExportStore
|
||||
/// </summary>
|
||||
Task<ExportCopy?> FindCopiedElsewhereAsync(string sha256, long? exceptAccountId = null, CancellationToken ct = default);
|
||||
|
||||
/// <summary>
|
||||
/// The SHA-256 of every file written converted or as a frame in a destination (any state, any destination): an
|
||||
/// import recognises them as copies of library files (tappa E3, Q37). No index on <c>copy_sha256</c>: one read per
|
||||
/// import run, bounded by the converted copies.
|
||||
/// </summary>
|
||||
Task<IReadOnlySet<string>> LoadConvertedCopyShasAsync(CancellationToken ct = default);
|
||||
|
||||
/// <summary>
|
||||
/// The current (Copied or Failed) rows of an original for an account in a destination, in any form but a frame,
|
||||
/// newest first: «già copiato» looks at the file, not at its format (decision D3 of tappa E3).
|
||||
|
||||
@@ -25,9 +25,119 @@ public interface IMediaConversionStore
|
||||
/// <summary>The conversions of one library file, in creation order.</summary>
|
||||
Task<IReadOnlyList<MediaConversion>> ListByMediaAsync(long mediaId, CancellationToken ct = default);
|
||||
|
||||
/// <summary>The conversions of the files of one entry, by file and creation order.</summary>
|
||||
Task<IReadOnlyList<MediaConversion>> ListByEntryAsync(long entryId, CancellationToken ct = default);
|
||||
|
||||
/// <summary>The conversions of these library files, by file and creation order.</summary>
|
||||
Task<IReadOnlyList<MediaConversion>> ListByMediaIdsAsync(IReadOnlyCollection<long> mediaIds, CancellationToken ct = default);
|
||||
|
||||
/// <summary>
|
||||
/// The paths (relative to the account folder) that conversions of the account's files record: Converted,
|
||||
/// Superseded and Removed rows (a rebuild does not count them as unknown files).
|
||||
/// </summary>
|
||||
Task<IReadOnlyList<string>> ListPathsByAccountAsync(long accountId, CancellationToken ct = default);
|
||||
|
||||
/// <summary>The conversions of the account's files that record this path (any state with a path), by key.</summary>
|
||||
Task<IReadOnlyList<MediaConversion>> FindByPathAsync(long accountId, string relativePath, CancellationToken ct = default);
|
||||
|
||||
/// <summary>Conversions whose converted file has this SHA-256 (a converted file found again is never a duplicate).</summary>
|
||||
Task<IReadOnlyList<MediaConversion>> FindBySha256Async(string sha256, CancellationToken ct = default);
|
||||
|
||||
/// <summary>The queue of the conversion, in order, by key.</summary>
|
||||
Task<IReadOnlyList<MediaConversion>> ListPendingAsync(long afterId = 0, int limit = 500, CancellationToken ct = default);
|
||||
|
||||
/// <summary>«Tolto»: these Converted or Superseded rows lost their file with their entry. Returns the rows changed.</summary>
|
||||
Task<int> MarkRemovedAsync(IReadOnlyCollection<long> ids, DateTimeOffset at, CancellationToken ct = default);
|
||||
|
||||
/// <summary>
|
||||
/// A library file left its entry («Tieni il più grande» on a file of a series): its queue and failures go, its rows
|
||||
/// with a file become «Tolto», in one transaction. Returns the rows marked «Tolto».
|
||||
/// </summary>
|
||||
Task<int> ForgetDeletedMediaAsync(long mediaId, DateTimeOffset at, CancellationToken ct = default);
|
||||
|
||||
/// <summary>
|
||||
/// The account's file changed from <paramref name="oldSha256"/> to <paramref name="newSha256"/> (spec §4.10
|
||||
/// «Superato»): the conversions made from the old bytes of the account's files that now have the new ones become
|
||||
/// Superseded (their files stay); Pending and retryable Failed rows take the new SHA-256. Returns the media ids of the
|
||||
/// files concerned (to queue them again).
|
||||
/// </summary>
|
||||
Task<IReadOnlyList<long>> SupersedeAsync(long accountId, string oldSha256, string newSha256, DateTimeOffset at, CancellationToken ct = default);
|
||||
|
||||
/// <summary>The setting of a format went off or changed: its queue is emptied (Converted rows and their files stay).</summary>
|
||||
Task<int> DeletePendingAsync(ExportFormat format, CancellationToken ct = default);
|
||||
|
||||
/// <summary>Drops one Pending row (a file already in the format by its bytes: nothing to record). False when it is not Pending.</summary>
|
||||
Task<bool> DeletePendingRowAsync(long id, CancellationToken ct = default);
|
||||
|
||||
/// <summary>How many rows are in each state; Failed rows with an <c>AsIs*</c> code are counted apart.</summary>
|
||||
Task<MediaConversionCounts> CountByStateAsync(CancellationToken ct = default);
|
||||
|
||||
/// <summary>
|
||||
/// Queues these files in these formats (Pending, <c>source_sha256</c> = the given SHA-256). A file that already has a
|
||||
/// current conversion in the format (Pending, Converted, or Failed, which holds the slot) is left as it is. Returns
|
||||
/// how many rows were added.
|
||||
/// </summary>
|
||||
Task<int> EnqueueAsync(IReadOnlyList<MediaConversionRequest> requests, DateTimeOffset at, CancellationToken ct = default);
|
||||
|
||||
/// <summary>
|
||||
/// «Anche i N già in libreria»: queues, in one statement, every present library file of each kind whose extension
|
||||
/// says it converts into the format given for its kind (null: that kind is not queued). Returns how many were added.
|
||||
/// </summary>
|
||||
Task<int> EnqueueExistingAsync(ExportFormat? photo, ExportFormat? video, DateTimeOffset at, CancellationToken ct = default);
|
||||
|
||||
/// <summary>What <see cref="EnqueueExistingAsync"/> would queue: files and their bytes.</summary>
|
||||
Task<(int Files, long Bytes)> CountExistingAsync(ExportFormat? photo, ExportFormat? video, CancellationToken ct = default);
|
||||
|
||||
/// <summary>
|
||||
/// Records a converted file just written (or adopted) for a Pending row, in one transaction (WP2.2 step 4): the row
|
||||
/// becomes Converted only if it is still Pending with <paramref name="sourceSha256"/> and its library file is still
|
||||
/// present with that SHA-256. Otherwise, with the file still present and unchanged, the current conversion of that
|
||||
/// file and format becomes Converted with this file, or a new row is added; with the file gone or changed nothing is
|
||||
/// recorded.
|
||||
/// </summary>
|
||||
Task<MediaConversionCommitOutcome> CommitAsync(MediaConversionCommit commit, CancellationToken ct = default);
|
||||
|
||||
/// <summary>«Riprova»: Failed rows go back to Pending, except those with an <c>AsIs*</c> code (they never convert). Returns how many.</summary>
|
||||
Task<int> ResetFailedAsync(DateTimeOffset at, CancellationToken ct = default);
|
||||
}
|
||||
|
||||
/// <summary>One file to queue in one format, made from these bytes.</summary>
|
||||
public sealed record MediaConversionRequest(long MediaId, ExportFormat Format, string SourceSha256);
|
||||
|
||||
/// <summary>The rows of the conversion for the library, by state.</summary>
|
||||
/// <param name="Pending">In the queue.</param>
|
||||
/// <param name="Converted">Converted files.</param>
|
||||
/// <param name="Failed">Failed, to try again («Riprova»).</param>
|
||||
/// <param name="AsIs">Failed for good: animated, not decodable, CMYK… («non si convertono»).</param>
|
||||
/// <param name="Superseded">Converted from bytes the library no longer has.</param>
|
||||
/// <param name="Removed">Their file went with the entry.</param>
|
||||
public sealed record MediaConversionCounts(int Pending, int Converted, int Failed, int AsIs, int Superseded, int Removed);
|
||||
|
||||
/// <summary>A converted file written for <paramref name="ConversionId"/>.</summary>
|
||||
/// <param name="ConversionId">The Pending row it was written for.</param>
|
||||
/// <param name="MediaId">Its library file.</param>
|
||||
/// <param name="Format">The format.</param>
|
||||
/// <param name="SourceSha256">The SHA-256 of the original it was made from.</param>
|
||||
/// <param name="RelativePath">Path relative to the account folder.</param>
|
||||
/// <param name="Bytes">Its size.</param>
|
||||
/// <param name="Sha256">Its SHA-256.</param>
|
||||
/// <param name="At">When it was converted.</param>
|
||||
/// <param name="Notes">What the conversion could not keep (loss codes, D19), or null.</param>
|
||||
public sealed record MediaConversionCommit(long ConversionId, long MediaId, ExportFormat Format, string SourceSha256,
|
||||
string RelativePath, long Bytes, string Sha256, DateTimeOffset At, string? Notes);
|
||||
|
||||
/// <summary>What <see cref="IMediaConversionStore.CommitAsync"/> did.</summary>
|
||||
public enum MediaConversionCommitOutcome
|
||||
{
|
||||
/// <summary>The Pending row is now Converted.</summary>
|
||||
Recorded,
|
||||
|
||||
/// <summary>The row had changed meanwhile; the file is recorded in the current row of its format, or a new one.</summary>
|
||||
Upserted,
|
||||
|
||||
/// <summary>Nothing recorded: the library file was deleted or changed meanwhile.</summary>
|
||||
SourceGone,
|
||||
|
||||
/// <summary>Nothing recorded: another converted file already holds the format of this library file.</summary>
|
||||
SlotTaken,
|
||||
}
|
||||
Reference in new issue
Block a user