E5: il lavoratore delle copie automatiche, all'avvio e ogni ora

AutoExportWorker copia da solo nelle cartelle con «Automatica» accesa:
il giro di recupero all'avvio e ogni ora (IClock), una passata due
minuti dopo l'ultima riga di _febe.jsonl (il segnale parte da
LibraryIngest, anche per le righe scritte in ritardo), subito con un
segnale urgente. Mai durante una sessione del motore: aspetta e dice
perché; i lavori di Alberto vengono prima e, finiti, il lavoro
automatico spostato riprende da solo (risposta 49). Al giro riprova le
cartelle in pausa (una copia manuale «In pausa» resta di Alberto,
risposta 48) e tutti i «Non riuscito» (risposta 50b); «Interrompi»
lo ferma fino alla fine della sosta (risposta 53). Un lavoro finito
non ne fa partire un altro da solo, così un file che non cambia
torna solo al giro. La composizione lo avvia solo nell'avvio normale
(mai nella dimostrazione) e lo ferma per primo alla chiusura.

Prove: AutoExportWorkerTests (le prove di accettazione di §15:
«Tolto» e «Superato» non si ricopiano, una cartella irraggiungibile
va in pausa e un giro dopo riprende, nessuna copia durante una
sessione), il segnale del giornale, la composizione.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-12-04 15:49:29 +01:00
1 parent 0ff4a0d632
commit e66e322d35
12 files changed
+1821 -5

No files matched your search

+22
View File
@@ -45,6 +45,9 @@ public sealed class FebeApp : IAsyncDisposable
/// <summary>How long a stop waits for «Cerca i video fermi» to give up the video it analyses.</summary>
private static readonly TimeSpan StillVideosWait = TimeSpan.FromSeconds(5);
/// <summary>The longest wait at the stop for an automatic copy to let go (real time: a share may not answer).</summary>
private static readonly TimeSpan ExportStopWait = TimeSpan.FromSeconds(5);
private readonly FebeAppOptions _options;
private readonly IFebePlatform _platform;
private readonly CancellationTokenSource _lifetime = new();
@@ -58,6 +61,7 @@ public sealed class FebeApp : IAsyncDisposable
private string? _temporaryFolder;
private RequestCatalog? _requestCatalog;
private ISessionCopier? _copier;
private AutoExportWorker? _autoExport;
private int _disposed;
private FebeApp(FebeAppOptions options, IFebePlatform platform, FebeLog log, IClock clock, IReadOnlyList<ConfigurationProblem> problems)
@@ -428,6 +432,12 @@ public sealed class FebeApp : IAsyncDisposable
InBackground(() => BringUpBrowserAsync(ingest, staging, services, engine, runner, search, lifetime));
InBackground(() => Alerts.WatchDiskSpaceAsync(lifetime));
InBackground(() => conversion.RunAsync(lifetime));
// The automatic export (tappa E5, D8): the start-up round at once, then a pass after each file saved in the
// library and every hour. Only in a normal start: never in the demo, nor in a start with problems.
var autoExport = Web.Services.GetRequiredService<AutoExportWorker>();
_autoExport = autoExport;
InBackground(() => autoExport.RunAsync(lifetime));
}
/// <summary>Runs <paramref name="work"/> in the background; the stop waits for it.</summary>
@@ -948,6 +958,18 @@ public sealed class FebeApp : IAsyncDisposable
Log.Info("arresto", "Arresto in corso.");
await Quietly(_platform.StoppingAsync).ConfigureAwait(false);
if (_autoExport is { } autoExport && Web is { } host)
{
// First the automatic export (tappa E5, D8): a session that ends while Febe stops must not start a copy. Its
// job is interrupted (its runs resume at the next start); a copy of Alberto's stops with the web host.
await Quietly(autoExport.StopAsync).ConfigureAwait(false);
await Quietly(async () =>
{
var exports = await host.Services.GetRequiredService<Febe.Web.Export.ExportHub>().GetAsync(CancellationToken.None).ConfigureAwait(false);
await exports.InterruptAutomaticAsync(CancellationToken.None).WaitAsync(ExportStopWait).ConfigureAwait(false);
}).ConfigureAwait(false);
}
if (Web is { } web)
{
await Quietly(() => web.StopAsync()).ConfigureAwait(false);