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

+23 -1
View File
@@ -159,7 +159,7 @@ public sealed class FolderSizes(IClock clock)
/// one at a time, never together with an import or a copy to external folders (the shared <see cref="LongWorkGate"/>,
/// spec §4.10). It never moves, renames or deletes a file (rule 12).
/// </summary>
public sealed class RebuildJob(IFebeStorage storage, FebeLibrary library, IClock clock, LibraryChanges changes, LongWorkGate gate)
public sealed class RebuildJob(IFebeStorage storage, FebeLibrary library, IClock clock, LibraryChanges changes, LongWorkGate gate, Export.ExportHub? exports = null)
{
private readonly Lock _gate = new();
private Task? _task;
@@ -220,6 +220,7 @@ public sealed class RebuildJob(IFebeStorage storage, FebeLibrary library, IClock
var report = await rebuilder.RebuildAsync(new RebuildOptions(), progress).ConfigureAwait(false);
State = State with { Running = false, Report = report, FinishedAt = clock.Now };
changes.Publish(new LibraryChange(clock.Now, null, "rebuild"));
await RecheckExportsAsync().ConfigureAwait(false);
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidOperationException or ArgumentException)
{
@@ -227,6 +228,27 @@ public sealed class RebuildJob(IFebeStorage storage, FebeLibrary library, IClock
}
}
/// <summary>
/// After a rebuild the account folders may be others: a destination of the copies that now sits inside one of them,
/// or around it, is paused with the reason (spec §4.10). A failure here leaves the rebuild done.
/// </summary>
private async Task RecheckExportsAsync()
{
if (exports is null)
{
return;
}
try
{
await (await exports.GetAsync().ConfigureAwait(false)).Destinations.RecheckAndPauseAsync(CancellationToken.None).ConfigureAwait(false);
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException or InvalidOperationException or ArgumentException)
{
// Nothing is lost: every copy checks its destination again before writing (and pauses it).
}
}
/// <summary>Progress reported on the calling thread (no synchronization context to post to).</summary>
private sealed class SyncProgress<T>(Action<T> action) : IProgress<T>
{