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:
1 parent
a112c92893
commit
4a7925ad23
30 files changed
+2299
-32
No files matched your search
+38
-1
@@ -11,6 +11,7 @@ using Febe.Core.Collection.Requests;
|
||||
using Febe.Core.Collection.Search;
|
||||
using Febe.Core.Domain;
|
||||
using Febe.Core.Engine;
|
||||
using Febe.Core.Export;
|
||||
using Febe.Core.Import;
|
||||
using Febe.Core.Library;
|
||||
using Febe.Core.Security;
|
||||
@@ -196,6 +197,7 @@ public sealed class FebeApp : IAsyncDisposable
|
||||
await StartWebAsync(hooks, services =>
|
||||
{
|
||||
services.AddSingleton(longWork);
|
||||
services.AddSingleton(ExportRootOptions.Docker(Path.Combine(_temporaryFolder, "esporta"), declared: false));
|
||||
services.AddSingleton<IFebeStorage>(Database);
|
||||
services.AddSingleton(library);
|
||||
services.AddSingleton<IClock>(Clock);
|
||||
@@ -220,7 +222,15 @@ public sealed class FebeApp : IAsyncDisposable
|
||||
var settings = await LibrarySettings.LoadAsync(Database.Settings, o.LibraryFolder, ct).ConfigureAwait(false);
|
||||
var libraryRoot = o.LibraryFolderFromSettings ? settings.LibraryRoot : o.LibraryFolder;
|
||||
var importRoot = o.ImportFolder is { } import ? Path.GetFullPath(import) : null;
|
||||
Log.Info("avvio", $"Febe {typeof(FebeApp).Assembly.GetName().Version?.ToString(3)}: dati in {data.Root}, libreria in {Path.GetFullPath(libraryRoot)}{(importRoot is null ? string.Empty : ", importazioni da " + importRoot)}, fuso {o.ZoneId}, lingua {o.Language}.");
|
||||
var exportRoot = hooks.ExportMounts is { } mounts ? o.ExportRoot with { Mounts = mounts } : o.ExportRoot;
|
||||
var exportState = ExportRoots.Evaluate(exportRoot);
|
||||
Log.Info("avvio", $"Febe {typeof(FebeApp).Assembly.GetName().Version?.ToString(3)}: dati in {data.Root}, libreria in {Path.GetFullPath(libraryRoot)}{(importRoot is null ? string.Empty : ", importazioni da " + importRoot)}{ExportLogText(exportRoot, exportState)}, fuso {o.ZoneId}, lingua {o.Language}.");
|
||||
if (exportRoot is { Root: not null, Declared: true } && !exportState.Active)
|
||||
{
|
||||
// Not a configuration problem: the engine starts, the copies stay off until the folder is mounted.
|
||||
Log.Warn("avvio", exportState.Problem ?? ExportRoots.NotDeclaredText);
|
||||
}
|
||||
|
||||
if (o.TestSite is not null)
|
||||
{
|
||||
Log.Warn("avvio", $"Modalità di sviluppo: il browser lavora sul sito di prova {o.TestSite.Authority}, non su Instagram.");
|
||||
@@ -329,6 +339,9 @@ public sealed class FebeApp : IAsyncDisposable
|
||||
await StartWebAsync(hooks, s =>
|
||||
{
|
||||
s.AddSingleton(longWork);
|
||||
s.AddSingleton(exportRoot);
|
||||
s.AddSingleton<IExportDisk>(hooks.ExportDisk ?? new SystemExportDisk(exportRoot.Mounts));
|
||||
s.AddSingleton<IEngineSessionState>(new RuntimeSessionState(services.Runtime));
|
||||
s.AddSingleton<IFebeStorage>(Database);
|
||||
s.AddSingleton(library);
|
||||
s.AddSingleton<IClock>(Clock);
|
||||
@@ -358,6 +371,11 @@ public sealed class FebeApp : IAsyncDisposable
|
||||
await Web.Services.GetRequiredService<Febe.Web.Import.ImportHub>().GetAsync(ct).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
// Copies to external folders (spec §4.10): built now, so that a copy interrupted by the last stop is marked at once.
|
||||
var exports = Web.Services.GetRequiredService<Febe.Web.Export.ExportHub>();
|
||||
await exports.GetAsync(ct).ConfigureAwait(false);
|
||||
LogRecoveredExports(exports.Recovered);
|
||||
|
||||
// Alerts (spec §13.3): from the engine's timeline and the free space of the two folders, to the shell's
|
||||
// notifications (the desktop's; in Docker the shell cannot notify and the channel stays silent) and Telegram.
|
||||
// The strip of the interface is the engine snapshot's. The library folder is read at every check: on Windows
|
||||
@@ -847,6 +865,25 @@ public sealed class FebeApp : IAsyncDisposable
|
||||
}
|
||||
}
|
||||
|
||||
private void LogRecoveredExports(int recovered)
|
||||
{
|
||||
if (recovered > 0)
|
||||
{
|
||||
Log.Info("esportazione", recovered == 1
|
||||
? "Una copia interrotta dall'arresto precedente: si riprende dalla Dashboard, scheda Esportazione."
|
||||
: $"{recovered.ToString(CultureInfo.InvariantCulture)} copie interrotte dall'arresto precedente: si riprendono dalla Dashboard, scheda Esportazione.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The part of the start-up line about the copies to external folders (Docker only).</summary>
|
||||
private static string ExportLogText(ExportRootOptions root, ExportRootState state) => root.Root switch
|
||||
{
|
||||
null => string.Empty,
|
||||
var folder when state.Active => ", copie esterne in " + folder,
|
||||
var folder when !root.Declared => $", copie esterne spente ({folder} non dichiarata)",
|
||||
var folder => $", copie esterne spente ({folder} non montata)",
|
||||
};
|
||||
|
||||
private void LogRecovered(int recovered)
|
||||
{
|
||||
if (recovered > 0)
|
||||
|
||||
Reference in new issue
Block a user