E5: il servizio avvia, cede e ferma le copie automatiche
Il servizio delle copie impara le partenze automatiche: TryStartAutomaticAsync e TryResumeAutomaticAsync non lanciano mai eccezioni perché Febe è occupata (occupato, niente da fare senza prendere il cancello, ferme), registrano solo i file da scrivere, un lavoro per cartella, e prendono il cancello con il permesso che cede: «Copia in…», «Riprendi», «Controlla le copie» e «Riprova» lo spostano con EnterAsync e aspettano che abbia salvato i suoi stati. I cambi di cartella passano da ChangeDestinationAsync, serializzati con le partenze automatiche: spegnere «Automatica» ferma subito la copia automatica di quella cartella e annulla i suoi lavori (risposta 52); un lavoro automatico non finito non blocca più il cambio di cartella. La copia annulla da sé un lavoro automatico la cui cartella non è più automatica. «Interrompi» di una copia automatica la ferma per un'ora, in memoria, con «Riprendi ora» (risposta 53). La prova di «Riprova» guarda anche lo spazio per il prossimo file prima di togliere una pausa. «Copia automatica in … finita» solo se il lavoro ha fatto qualcosa (risposta 54). I «Non riuscito» restano candidati di ogni giro (risposta 50); il percorso troppo lungo ha la sua nota. La chiusura aspetta il lavoro al più 10 secondi. Il segnale parte dal nucleo quando una cartella si accende o prende più file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cfd0ef88d7
commit
0f69a01f88
10 files changed
+1872
-123
No files matched your search
@@ -213,34 +213,61 @@ public sealed class ExportDestinationsTests
|
||||
Assert.AreEqual(ContentTypes.Tagged, (await bed.Db.Exports.GetDestinationAsync(usb.Id, ct))!.ContentTypes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tappa E5 (D3, D4): turning «Automatica» on, adding types while on, removing an own folder and turning
|
||||
/// «Esporta questo account» on wake the automatic export at once (an urgent signal); the save itself copies nothing
|
||||
/// and records no job (the worker's pass does). «Da quando» is kept while on, forgotten when off.
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public async Task AutomaticIsStoredButNothingIsQueued()
|
||||
public async Task TurningAutomaticOnSignalsTheAutomaticExport()
|
||||
{
|
||||
var ct = TestContext.CancellationToken;
|
||||
await using var bed = await ExportTestBed.CreateAsync();
|
||||
var signal = new AutoExportSignal();
|
||||
await using var bed = await ExportTestBed.CreateAsync(env => env with { AutoSignal = signal });
|
||||
await bed.PostAsync(bed.Marta, "920", 1);
|
||||
var spec = new DestinationSpec(ExportScope.General, null, bed.Usb, null, ContentTypes.All, null, null, null, Automatic: true, OnlyNew: true);
|
||||
var spec = new DestinationSpec(ExportScope.General, null, bed.Usb, null, ContentTypes.PostPhotos, null, null, null, Automatic: true, OnlyNew: true);
|
||||
var next = signal.Next();
|
||||
var saved = (await bed.Service.Destinations.CreateAsync(spec, ct)).Destination;
|
||||
var stored = (await bed.Db.Exports.GetDestinationAsync(saved.Id, ct))!;
|
||||
Assert.IsTrue(stored.Automatic);
|
||||
Assert.AreEqual(Make.T0, stored.AutomaticSince);
|
||||
Assert.AreEqual(1, signal.Count);
|
||||
Assert.IsTrue(await next, "turned on: urgent, no settle wait");
|
||||
|
||||
// Tappa E2 does not act on it: no job, nothing written, nothing running.
|
||||
// The save copies nothing by itself: no job, nothing written, nothing running.
|
||||
Assert.IsFalse(bed.Service.IsBusy);
|
||||
Assert.IsEmpty(await bed.Db.Exports.ListRunsAsync(ct));
|
||||
Assert.IsEmpty(Directory.GetFileSystemEntries(bed.Usb));
|
||||
|
||||
// Still on: «da quando» is kept; off: it goes; on with «tutti»: no date.
|
||||
// Still on: «da quando» is kept, and a new label wakes nothing; off: it goes; on with «tutti»: no date.
|
||||
bed.Clock.Now = Make.T0.AddDays(3);
|
||||
await bed.Service.Destinations.UpdateAsync(saved.Id, spec with { Label = "Disco" }, ct);
|
||||
Assert.AreEqual(Make.T0, (await bed.Db.Exports.GetDestinationAsync(saved.Id, ct))!.AutomaticSince);
|
||||
Assert.AreEqual(1, signal.Count);
|
||||
await bed.Service.Destinations.UpdateAsync(saved.Id, spec with { Automatic = false }, ct);
|
||||
Assert.IsTrue((await bed.Db.Exports.GetDestinationAsync(saved.Id, ct)) is { Automatic: false, AutomaticSince: null });
|
||||
Assert.AreEqual(1, signal.Count, "turned off: nothing to wake");
|
||||
await bed.Service.Destinations.UpdateAsync(saved.Id, spec with { OnlyNew = false }, ct);
|
||||
Assert.IsTrue((await bed.Db.Exports.GetDestinationAsync(saved.Id, ct)) is { Automatic: true, AutomaticSince: null });
|
||||
Assert.AreEqual(2, signal.Count);
|
||||
await bed.Service.Destinations.UpdateAsync(saved.Id, spec with { Automatic = false }, ct);
|
||||
await bed.Service.Destinations.UpdateAsync(saved.Id, spec, ct);
|
||||
Assert.AreEqual(Make.T0.AddDays(3), (await bed.Db.Exports.GetDestinationAsync(saved.Id, ct))!.AutomaticSince);
|
||||
Assert.AreEqual(3, signal.Count);
|
||||
|
||||
// A type added while on (answer 55: no new question), an own folder removed, an account switched on again.
|
||||
await bed.Service.Destinations.UpdateAsync(saved.Id, spec with { ContentTypes = ContentTypes.PostPhotos | ContentTypes.Stories }, ct);
|
||||
Assert.AreEqual(4, signal.Count);
|
||||
await bed.Service.Destinations.UpdateAsync(saved.Id, spec with { ContentTypes = ContentTypes.Stories }, ct);
|
||||
Assert.AreEqual(4, signal.Count, "fewer types: nothing new goes");
|
||||
var own = await bed.OwnAsync(bed.Luca, "luca-nas", ct: ct);
|
||||
Assert.AreEqual(4, signal.Count, "an own folder without «Automatica»");
|
||||
await bed.Service.Destinations.RetireAsync(own.Id, ct);
|
||||
Assert.AreEqual(5, signal.Count);
|
||||
await bed.Service.Destinations.SetAccountEnabledAsync(bed.Luca.Id, false, ct);
|
||||
Assert.AreEqual(5, signal.Count);
|
||||
await bed.Service.Destinations.SetAccountEnabledAsync(bed.Luca.Id, true, ct);
|
||||
Assert.AreEqual(6, signal.Count);
|
||||
Assert.IsEmpty(await bed.Db.Exports.ListRunsAsync(ct));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user