E2: API delle copie esterne, composizione e dimostrazione

Le copie esterne diventano usabili dall'interfaccia: ExportHub costruisce
l'unico ExportService del web (segna «interrotto» ciò che l'arresto ha
fermato e avvisa le pagine a lavoro finito), ExportApi espone cartelle,
scelta e controllo della cartella, «Copia in…» (piano e avvio), «Copia di
nuovo», avanzamento, lavori, ripresa, annullamento e resoconto.

Gli endpoint esistenti portano le copie: filtro copies= della Libreria,
segno «Copiato» / «Copiato in parte 1/3» sulle tessere, copie di ogni file
nel visualizzatore, riquadro «Copie esterne» e interruttore «Esporta questo
account» nella scheda. Una cartella di account o della libreria che
finirebbe dentro (o attorno a) una cartella delle copie è rifiutata; dopo
una ricostruzione le cartelle in conflitto vanno in pausa.

Composizione: in Docker le copie si scrivono solo sotto /esporta, e solo
con --esporta/FEBE_ESPORTA e un montaggio (riga di avvio e avviso se manca);
sul desktop qualsiasi cartella con la finestra del sistema e lo spazio
libero misurato anche sulle condivisioni di rete. La dimostrazione ha una
cartella generale, una propria, un account non esportato e copie vere in
ogni stato, scritte dal motore nella sua cartella temporanea.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-27 11:42:02 +01:00
1 parent a112c92893
commit 4a7925ad23
30 files changed
+2299 -32

No files matched your search

+219
View File
@@ -0,0 +1,219 @@
namespace Febe.Web.Api;
// JSON shapes of the copies to external folders (spec §4.10, tappa E2). Same conventions as Dtos.cs: English camelCase
// names, Italian texts, times as LocalTimeDto. Names of states and types on the wire:
// scope «general»|«account»; types «postFoto», «postVideo», «storie», «evidenza», «taggati», «profilo»;
// copy states «copied», «removed», «superseded», «failed»; job states «running», «interrupted», «paused», «completed»,
// «cancelled»; file states «pending», «copied», «adopted», «alreadyCopied», «skipped», «missing», «failed».
/// <summary>
/// Where copies can go. <paramref name="Docker"/>: destinations are subfolders of <paramref name="Root"/> (the page
/// lists them); otherwise any folder, with the native picker when <paramref name="PickFolder"/>.
/// <paramref name="Active"/> false: nothing can be written, <paramref name="Problem"/> says why.
/// </summary>
public sealed record ExportRootDto(bool Docker, bool Active, string? Root, string? Problem, bool PickFolder);
/// <summary>The library's naming schemes, to prefill «Uno schema suo», and the placeholders.</summary>
public sealed record ExportSchemesDto(string General, string Highlight, string Profile, IReadOnlyList<string> Placeholders);
/// <summary>
/// A destination. <paramref name="Display"/> is the folder as shown («/esporta/usb» in Docker). <paramref name="Types"/>
/// are the wire names of the content types; null schemes are «Come la libreria». <paramref name="Problem"/>: the reason
/// of its pause (or, with <c>/status</c>, why it does not answer now). <paramref name="Counts"/>: copies per state
/// (<c>copied</c>, <c>removed</c>, <c>superseded</c>, <c>failed</c>). <paramref name="Reachable"/> and
/// <paramref name="FreeBytes"/> only from <c>/status</c>. <paramref name="Orphan"/>: an own folder whose account was
/// removed («era di @<paramref name="FormerUsername"/>»).
/// </summary>
public sealed record ExportDestinationDto(
long Id,
string Scope,
long? AccountId,
string? Username,
string Label,
string RootPath,
string Display,
IReadOnlyList<string> Types,
string? NamingScheme,
string? HighlightNamingScheme,
string? ProfileNamingScheme,
bool Automatic,
LocalTimeDto? PausedAt,
string? Problem,
IReadOnlyDictionary<string, int> Counts,
bool? Reachable = null,
long? FreeBytes = null,
bool Orphan = false,
string? FormerUsername = null);
/// <summary>
/// <c>GET /api/export</c>: Impostazioni → Esportazione and the notice of the Dashboard. <paramref name="SamePost"/>:
/// <c>onePerAccount</c> or <c>oneOnly</c>. <paramref name="UnfinishedRuns"/>: interrupted or paused jobs («Riprendi»).
/// </summary>
public sealed record ExportOverviewDto(
ExportRootDto Root,
string SamePost,
ExportDestinationDto? General,
IReadOnlyList<ExportDestinationDto> Own,
IReadOnlyList<long> ActiveRunIds,
int UnfinishedRuns,
ExportSchemesDto Library);
/// <summary><c>PUT /api/export/settings</c>: «Lo stesso post in due account», <c>onePerAccount</c> or <c>oneOnly</c>.</summary>
public sealed record ExportSettingsRequest(string SamePost);
/// <summary>Docker: the subfolders of a folder of <c>/esporta</c>. <paramref name="Relative"/> is "" for the root.</summary>
public sealed record ExportFolderListDto(string Relative, string? Parent, string Display, IReadOnlyList<SourceFolderDto> Folders);
/// <summary><c>POST /api/export/pick-folder</c>: the destination being changed, to open the picker on its folder.</summary>
public sealed record ExportPickRequest(long? DestinationId);
/// <summary>The check of a candidate folder (before saving). <paramref name="Fat32"/>: files over 4 GB cannot go there.</summary>
public sealed record ExportFolderCheckDto(bool Accepted, string FullPath, string Display, string? Problem, long? FreeBytes, bool Fat32);
/// <summary>The «Risultato» of a destination's naming. <paramref name="Scope"/>: general or account; null schemes are the library's.</summary>
public sealed record ExportNamingPreviewRequest(string Scope, string? General, string? Highlight, string? Profile);
/// <summary>
/// A destination to add or change. <paramref name="Path"/>: in Docker the folder relative to <c>/esporta</c> (as listed),
/// elsewhere the full path. <paramref name="Types"/>: wire names, at least one. Null or empty schemes: «Come la
/// libreria». «Automatica» is stored only (tappa E5 acts on it).
/// </summary>
public sealed record ExportDestinationRequest(
string Scope,
long? AccountId,
string Path,
string? Label,
IReadOnlyList<string> Types,
string? NamingScheme,
string? HighlightNamingScheme,
string? ProfileNamingScheme,
bool Automatic = false,
bool OnlyNew = true);
/// <summary>A saved destination (a change of folder gives a new id) and the warnings of its schemes.</summary>
public sealed record ExportDestinationSavedDto(ExportDestinationDto Destination, IReadOnlyList<string> Warnings);
/// <summary>
/// What a «Copia in…» copies: exactly one of <paramref name="MediaIds"/> (files of «Tutte le foto» or the viewer),
/// <paramref name="EntryIds"/> (a grouped selection), <paramref name="Query"/> (the filter of the Libreria, as its query
/// string, with <paramref name="Mode"/> <c>grouped</c> or <c>files</c>) or <paramref name="AccountId"/> (every file of
/// the account). <paramref name="CopyAgain"/>: «Copia di nuovo anche i tolti o superati».
/// </summary>
public sealed record CopyJobRequestDto(
IReadOnlyList<long>? MediaIds,
IReadOnlyList<long>? EntryIds,
string? Query,
string? Mode,
long? AccountId,
bool CopyAgain = false);
/// <summary>A destination of a plan. <paramref name="Problem"/>: why it cannot be written now (paused, not reachable).</summary>
public sealed record ExportPlanDestinationDto(
long Id,
string Label,
string Display,
string Scope,
string? Username,
int Files,
long Bytes,
bool Paused,
string? Problem,
long? FreeBytes);
/// <summary>
/// The summary of «Copia in…» (spec §10.3). <paramref name="Files"/>/<paramref name="Bytes"/>: what will be written
/// (with «Copia di nuovo» the tolti/superati too). <paramref name="NotExported"/>: of accounts that are not exported
/// (switch off, no destination, type not taken). <paramref name="Missing"/>: not in the library.
/// </summary>
public sealed record ExportPlanDto(
int Files,
long Bytes,
int AlreadyCopied,
int RemovedOrSuperseded,
int NotExported,
int Missing,
IReadOnlyList<ExportPlanDestinationDto> Destinations);
/// <summary>The jobs a «Copia in…» started, one per destination (empty: nothing to copy), and the plan it followed.</summary>
public sealed record ExportJobDto(IReadOnlyList<long> RunIds, ExportPlanDto Plan, string Message);
/// <summary>«Copia di nuovo» of a copy «Tolto» or «Superato» (the viewer).</summary>
public sealed record CopyAgainRequest(long CopyId);
/// <summary>
/// <c>GET /api/export/progress</c>, polled by the Dashboard tab. <paramref name="Phase"/>: preparing, checking,
/// waitingForSession, copying, finished. <paramref name="ByState"/>: files of the job per state.
/// </summary>
public sealed record ExportProgressDto(
long? RunId,
string Phase,
double Fraction,
int FilesDone,
int FilesTotal,
long BytesDone,
long BytesTotal,
string? CurrentFile,
string? Destination,
IReadOnlyDictionary<string, int> ByState,
bool Running,
string? Error);
/// <summary>An export job. <paramref name="Kind"/>: copy or recognize; <paramref name="Origin"/>: manual or automatic.</summary>
public sealed record ExportRunDto(
long Id,
long DestinationId,
string Destination,
string Kind,
string Origin,
string State,
LocalTimeDto StartedAt,
LocalTimeDto? CompletedAt,
string? Error,
int Total,
int Done,
bool Running = false);
/// <summary>The files of one account in a job (<paramref name="Copied"/> counts written and adopted files).</summary>
public sealed record ExportReportAccountDto(long? AccountId, string Username, int Copied, int AlreadyCopied, int Skipped, int Failed);
/// <summary>A file of the report that needs a look, with its reason in Italian.</summary>
public sealed record ExportReportLineDto(long ItemId, string Username, string? Path, string State, string Text);
/// <summary>The report of a job (at most 200 problems).</summary>
public sealed record ExportReportDto(
ExportRunDto Run,
IReadOnlyDictionary<string, int> ByState,
long BytesCopied,
IReadOnlyList<ExportReportAccountDto> Accounts,
IReadOnlyList<ExportReportLineDto> Problems);
/// <summary>
/// A copy of a file of the viewer (spec §4.6, §4.10). <paramref name="State"/>: copied, removed, superseded, failed;
/// <paramref name="Variant"/>: whole (tappa E2 copies originals only). <paramref name="ForAccount"/>: with «Una copia
/// sola», the account it was copied for when it is another one. <paramref name="CanCopyAgain"/>: «Copia di nuovo».
/// </summary>
public sealed record MediaCopyDto(
long CopyId,
string Destination,
bool DestinationRetired,
string State,
string Variant,
string? Format,
long? FrameAtMs,
LocalTimeDto At,
string? ForAccount,
bool CanCopyAgain);
/// <summary>
/// «Copie esterne» of the account card. <paramref name="Destination"/>: the effective one (its own folder, else the
/// general folder), null when there is none. Counts are of due files (decision D3 of tappa E2): with the switch off
/// they are zero.
/// </summary>
public sealed record ExportAccountDto(
bool Enabled,
bool HasOwnFolder,
ExportDestinationDto? Destination,
int Due,
int NotCopied,
int RemovedOrSuperseded,
int Failed);