E2: motore delle copie esterne (porta, destinazioni, piano, copia)
Prima metà della tappa E2 «Copie esterne» (#58), parte Core e Data: - porta del lavoro lungo: importazione, copia e ricostruzione mai insieme; - radice /esporta in Docker con mountinfo, controllo delle cartelle con il file di prova, destinazioni con «Esporta questo account» acceso se Alberto non ha mai scelto (decisione del 27/11/2026); - filtro «Copie», segni delle tessere e conteggi dell'account sui soli file dovuti (D3); - percorsi «Come la libreria», segmento dell'account nella cartella generale, 240 caratteri, storia in evidenza; - piano di «Copia in…», un lavoro per destinazione, copia in .part con SHA-256 riletto dal disco, nome libero, mai sovrascrivere, adozione per percorso, pausa della destinazione su prova, spazio e FAT32, attesa fuori dalle sessioni del motore, ripresa e recupero; - .part rimossi solo nelle cartelle degli elementi di lavori non finiti; - «Tolto» e «Superato» (agganci in importazione, scaricamenti, doppioni e ricostruzione), mai ricopiati da soli; - rapporti e testi in italiano, prove del lavoro di copia. Interfaccia, API e composizione restano alla parte successiva. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
213b89a618
commit
a112c92893
41 files changed
+5370
-27
No files matched your search
@@ -0,0 +1,114 @@
|
||||
using Febe.Core.Domain;
|
||||
using Febe.Core.Storage;
|
||||
|
||||
namespace Febe.Core.Export;
|
||||
|
||||
/// <summary>What a «Copia in…» is asked for (spec §4.10 «Manuale sempre»).</summary>
|
||||
public abstract record ExportSelection
|
||||
{
|
||||
private ExportSelection()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>Files by id: a selection of «Tutte le foto», a file of the viewer.</summary>
|
||||
public sealed record Media(IReadOnlyList<long> MediaIds) : ExportSelection;
|
||||
|
||||
/// <summary>Entries by id: a grouped selection, an entry of the viewer.</summary>
|
||||
public sealed record Entries(IReadOnlyList<long> EntryIds) : ExportSelection;
|
||||
|
||||
/// <summary>The current filter («Copia i file in…» of the CSV menu).</summary>
|
||||
public sealed record Filter(LibraryFilter LibraryFilter, MosaicMode Mode) : ExportSelection;
|
||||
|
||||
/// <summary>Every file of an account (the account card).</summary>
|
||||
public sealed record Account(long AccountId) : ExportSelection;
|
||||
}
|
||||
|
||||
/// <summary>A «Copia in…»: what to copy, whether «Tolti» and «Superati» are copied again (D9), who asked.</summary>
|
||||
public sealed record ExportJobRequest(ExportSelection Selection, bool CopyAgain = false, ExportRunOrigin Origin = ExportRunOrigin.Manual);
|
||||
|
||||
/// <summary>
|
||||
/// What a «Copia in…» would do (database only, decisions D3 and D9 of tappa E2). Each file goes to the effective
|
||||
/// destination of its account (D5).
|
||||
/// </summary>
|
||||
/// <param name="Files">Files to write.</param>
|
||||
/// <param name="Bytes">Their bytes.</param>
|
||||
/// <param name="AlreadyCopied">Already in their destination (or, with «Una copia sola», copied for another account).</param>
|
||||
/// <param name="RemovedOrSuperseded">
|
||||
/// «Tolti o superati»: never copied again by themselves. With <see cref="ExportJobRequest.CopyAgain"/> they are also
|
||||
/// counted in <paramref name="Files"/> and <paramref name="Bytes"/>, since they will be written.
|
||||
/// </param>
|
||||
/// <param name="NotExported">«Esporta questo account» off, no destination, or a content type the destination does not take.</param>
|
||||
/// <param name="Missing">«File non presente in libreria».</param>
|
||||
/// <param name="Destinations">Each destination that gets files, with whether it answers now.</param>
|
||||
public sealed record ExportPlan(
|
||||
int Files,
|
||||
long Bytes,
|
||||
int AlreadyCopied,
|
||||
int RemovedOrSuperseded,
|
||||
int NotExported,
|
||||
int Missing,
|
||||
IReadOnlyList<ExportPlanDestination> Destinations)
|
||||
{
|
||||
public static ExportPlan Empty { get; } = new(0, 0, 0, 0, 0, 0, []);
|
||||
}
|
||||
|
||||
/// <summary>A destination of a plan.</summary>
|
||||
/// <param name="Username">The account of an own folder; null for the general folder.</param>
|
||||
/// <param name="Files">Files to write there.</param>
|
||||
/// <param name="Paused">The destination is paused (its last check failed).</param>
|
||||
/// <param name="Problem">Why it cannot be written now (not reachable, not mounted, paused), in Italian; null when fine.</param>
|
||||
/// <param name="FreeBytes">Free space, when it can be measured.</param>
|
||||
public sealed record ExportPlanDestination(
|
||||
long DestinationId,
|
||||
string Label,
|
||||
string RootPath,
|
||||
ExportScope Scope,
|
||||
string? Username,
|
||||
int Files,
|
||||
long Bytes,
|
||||
bool Paused,
|
||||
string? Problem,
|
||||
long? FreeBytes);
|
||||
|
||||
/// <summary>What the export job is doing.</summary>
|
||||
public enum ExportPhase
|
||||
{
|
||||
Preparing,
|
||||
|
||||
/// <summary>«Controlla le copie».</summary>
|
||||
Checking,
|
||||
|
||||
/// <summary>An engine session is running: copies wait for it to end (decision D11).</summary>
|
||||
WaitingForSession,
|
||||
|
||||
Copying,
|
||||
|
||||
Finished,
|
||||
}
|
||||
|
||||
/// <summary>Progress of the export job, for the progress card (polled, D20).</summary>
|
||||
/// <param name="RunId">The job's run being worked on; null for «Controlla le copie» and when nothing ever ran.</param>
|
||||
/// <param name="BytesTotal">Bytes of the files still pending when the run (re)started, plus those done since; 0 when unknown.</param>
|
||||
public sealed record ExportProgress(
|
||||
long? RunId,
|
||||
ExportPhase Phase,
|
||||
int FilesDone,
|
||||
int FilesTotal,
|
||||
long BytesDone,
|
||||
long BytesTotal,
|
||||
string? CurrentFile,
|
||||
string? DestinationLabel,
|
||||
IReadOnlyDictionary<ExportItemState, int> ByState,
|
||||
DateTimeOffset UpdatedAt)
|
||||
{
|
||||
/// <summary>0..1: by bytes when known, otherwise by files.</summary>
|
||||
public double Fraction => BytesTotal > 0
|
||||
? Math.Clamp((double)BytesDone / BytesTotal, 0, 1)
|
||||
: FilesTotal > 0 ? Math.Clamp((double)FilesDone / FilesTotal, 0, 1) : 0;
|
||||
}
|
||||
|
||||
/// <summary>What <c>ExportService.StartAsync</c> did: one run per destination (D6), and the plan it followed.</summary>
|
||||
public sealed record ExportStart(IReadOnlyList<ExportRun> Runs, ExportPlan Plan);
|
||||
|
||||
/// <summary>The export job ended (however it ended): the runs it worked on, and whether copies may have changed.</summary>
|
||||
public sealed record ExportJobFinished(IReadOnlyList<long> RunIds, bool CopiesChanged);
|
||||
Reference in new issue
Block a user