From c0e04d293057465d6dfb3bcd15756ffe4eca8116 Mon Sep 17 00:00:00 2001 From: Alberto Balbo Date: Fri, 4 Dec 2026 21:16:36 +0100 Subject: [PATCH] =?UTF-8?q?E5:=20commenti=20di=20FebeApp=20e=20=C2=ABRipre?= =?UTF-8?q?ndi=20ora=C2=BB=20senza=20segnale=20a=20lavoratore=20fermo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit La proprietà AutoExportStarted stava fra la documentazione di StartedMessage e il metodo; il riassunto di DisposeAsync non diceva che la copia automatica si ferma per prima. L'API «Riprendi ora» chiede una passata solo se il lavoratore gira davvero: è registrato sempre, ma nella dimostrazione e in un avvio con problemi non gira e nessuno ascolta il segnale. Co-Authored-By: Claude Opus 5.5 --- src/Febe.App/FebeApp.cs | 10 +++++----- src/Febe.Web/Api/ExportApi.cs | 5 +++-- tests/Febe.Tests/Web/ExportApiTests.Automatic.cs | 8 ++++++++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/Febe.App/FebeApp.cs b/src/Febe.App/FebeApp.cs index 7339236..0a2fd31 100644 --- a/src/Febe.App/FebeApp.cs +++ b/src/Febe.App/FebeApp.cs @@ -744,14 +744,14 @@ public sealed class FebeApp : IAsyncDisposable } } + /// Tests only: the composition started the automatic export (a normal start; never with problems). + internal bool AutoExportStarted => _autoExport is not null; + /// /// The start-up line of the engine, with what it waits for: the same state as the engine's own gate /// (), so that the log never says «collegato» while the monitor /// says «Serve «Ho finito»». /// - /// Tests only: the composition started the automatic export (a normal start; never with problems). - internal bool AutoExportStarted => _autoExport is not null; - internal static string StartedMessage(BrowserConnectionService connection) { ArgumentNullException.ThrowIfNull(connection); @@ -948,8 +948,8 @@ public sealed class FebeApp : IAsyncDisposable } /// - /// Stops everything in order: the shell's own first (remote view), interface, engine, downloads, alerts, import, - /// pipeline, browser, database. + /// Stops everything in order: the shell's own first (remote view), then the automatic export (tappa E5), interface, + /// engine, downloads, alerts, import, pipeline, browser, database. /// public async ValueTask DisposeAsync() { diff --git a/src/Febe.Web/Api/ExportApi.cs b/src/Febe.Web/Api/ExportApi.cs index 953f369..412e147 100644 --- a/src/Febe.Web/Api/ExportApi.cs +++ b/src/Febe.Web/Api/ExportApi.cs @@ -276,13 +276,14 @@ public static class ExportApi endpoints.MapPost("/api/export/automatic/resume", async (ExportHub hub, IServiceProvider services, CancellationToken ct) => { var service = await hub.GetAsync(ct).ConfigureAwait(false); - if (services.GetService(typeof(AutoExportWorker)) is AutoExportWorker worker) + if (services.GetService(typeof(AutoExportWorker)) is AutoExportWorker { Running: true } worker) { await worker.ResumeNowAsync(ct).ConfigureAwait(false); } else { - // No worker (the demonstration, a start with problems): nothing to wake, the API sends no signal. + // The worker is registered always but runs only after a normal start (not in the demonstration, not in a + // start with problems): nothing to wake, the API sends no signal. service.ReleaseAutomaticHold(); } diff --git a/tests/Febe.Tests/Web/ExportApiTests.Automatic.cs b/tests/Febe.Tests/Web/ExportApiTests.Automatic.cs index 6d7c101..b40c3dc 100644 --- a/tests/Febe.Tests/Web/ExportApiTests.Automatic.cs +++ b/tests/Febe.Tests/Web/ExportApiTests.Automatic.cs @@ -368,6 +368,14 @@ public sealed partial class ExportApiTests var worker = server.App.Services.GetRequiredService(); Assert.AreEqual(JsonValueKind.Null, (await server.GetJsonAsync("/api/export")).GetProperty("automatic").ValueKind, "not started yet"); + // Registered but not running: «Riprendi ora» releases the hold and asks no pass, since nothing listens. + var idle = await server.App.Services.GetRequiredService().GetAsync(); + idle.HoldAutomatic(clock.Now + TimeSpan.FromHours(1)); + var signals = signal.Count; + Assert.AreEqual(HttpStatusCode.OK, (await server.SendJsonAsync(HttpMethod.Post, "/api/export/automatic/resume")).Status); + Assert.IsNull(idle.AutomaticHeldUntil); + Assert.AreEqual(signals, signal.Count, "no signal without the loop"); + using var stop = new CancellationTokenSource(); var loop = Task.Run(() => worker.RunAsync(stop.Token)); try