E5: Dashboard e finestra della cartella dicono il vero sulle copie automatiche

«Riprendi» e «Riprendi tutte» restano attivi mentre lavora una copia
automatica, che cede il passo (risposta 49): li spegne solo un lavoro di
Alberto. «Annulla» di un lavoro automatico dice che i file ripartono da
soli; la risposta a «Interrompi» dice l'ora come il resto («all'1:20»,
«domani alle 0:30»), e «dal» si elide («dall'8 dicembre»). Nella
finestra della cartella «Salva» aspetta il conto dei tipi di adesso, un
conto non riuscito si richiede e il suo errore resta, il fuoco della
tastiera non salta; una nota dice perché «Automatica» è spenta senza
cartelle scrivibili. «Riprendi ora» torna attivo se la richiesta
fallisce. Il conto dei file che aspettano si condivide fra letture e non
si fa per la scheda di un account senza cartella sua; sul telefono i
pulsanti della tabella delle cartelle vanno a capo. Prove nuove: chiusura
che ferma prima il lavoratore, percorso troppo lungo, attesa di due
minuti dall'ultimo file e tetto di un quarto d'ora.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-12-04 20:07:48 +01:00
1 parent 3c48582067
commit 9c7f2f1ad5
16 files changed
+334 -69

No files matched your search

@@ -375,6 +375,43 @@ public sealed class AutoExportWorkerTests
Assert.IsTrue(File.Exists(bed.GeneralCopy(bed.Luca, post.Media[0])));
}
/// <summary>
/// A folder whose path leaves no room for the names of the scheme (it passes the folder check, which asks room for
/// one short name only): each file is «Non riuscito» with «Percorso troppo lungo per la cartella» and the run goes on
/// to the end; a signal pass leaves them, every round tries them again (answer 50).
/// </summary>
[TestMethod]
public async Task APathTooLongFailsEachFileAndTheRoundTriesItAgain()
{
var ct = TestContext.CancellationToken;
await using var bed = await ExportTestBed.CreateAsync();
var post = await bed.PostAsync(bed.Luca, "t01", 1, 2);
var room = WindowsFileNames.MaxPathLength - 4 - bed.Temp.Path.Length - 1;
var longRoot = bed.Temp.Combine("l" + new string('x', room - 1));
Directory.CreateDirectory(longRoot);
var usb = await TurnOnAsync(bed, await bed.GeneralAsync(folder: longRoot, ct: ct), onlyNew: false, ct);
var worker = Worker(bed);
Assert.AreEqual(AutoExportPass.Started, await worker.RunOnceAsync(round: true, ct));
await bed.Service.WaitAsync(ct);
var run = (await bed.Db.Exports.ListRunsAsync(ct)).Single();
Assert.AreEqual(ExportRunState.Completed, run.State, "the run goes to the end");
var items = await bed.ItemsAsync(run.Id, ct);
Assert.HasCount(2, items);
Assert.IsTrue(items.All(i => i is { State: ExportItemState.Failed, Note: ExportText.Notes.PathTooLong }), string.Join(", ", items.Select(i => $"{i.State} {i.Note}")));
var copies = await bed.Db.Exports.ListCopiesAsync(usb.Id, ct: ct);
Assert.HasCount(2, copies);
Assert.IsTrue(copies.All(c => c.State == ExportCopyState.Failed && c.LastError is not null), "«Non riuscito», with the reason");
Assert.AreEqual("Percorso troppo lungo per la cartella", ExportText.Note(ExportText.Notes.PathTooLong));
Assert.IsFalse(Directory.EnumerateFileSystemEntries(longRoot).Any(), "nothing written");
Assert.AreEqual(AutoExportPass.NothingToDo, await worker.RunOnceAsync(round: false, ct), "a signal pass leaves a «Non riuscito»");
Assert.AreEqual(AutoExportPass.Started, await worker.RunOnceAsync(round: true, ct), "every round tries it again");
await bed.Service.WaitAsync(ct);
Assert.HasCount(2, await bed.Db.Exports.ListRunsAsync(ct));
Assert.IsTrue(post.Media.All(m => !File.Exists(Path.Combine(longRoot, "luca.demo", LibraryLayout.ToPlatform(m.RelativePath!)))));
}
/// <summary>
/// One unfinished automatic run per destination: one stopped by an error is resumed only by the round, and meanwhile
/// the destination gets no other automatic run.
@@ -636,14 +673,20 @@ public sealed class AutoExportWorkerTests
await IdleAsync(bed, worker, clock!, ct);
var asked = clock!.Asked;
var first = clock.Now;
var post = await bed.PostAsync(bed.Luca, "g01", 1);
var due = await clock.WaitForDelayAsync(asked, ct);
Assert.AreEqual(clock.Now + TimeSpan.FromMinutes(2), due, "the settle");
Assert.AreEqual(first + TimeSpan.FromMinutes(2), await clock.WaitForDelayAsync(asked, ct), "the settle");
// A second file 90 s later: the settle starts again from it.
clock.Advance(TimeSpan.FromSeconds(90));
asked = clock.Asked;
var second = await bed.PostAsync(bed.Luca, "g02", 2);
await clock.WaitForDelayAsync(asked + 1, ct);
clock.Advance(TimeSpan.FromMinutes(1));
await Task.Delay(50, ct);
Assert.IsFalse(File.Exists(bed.GeneralCopy(bed.Luca, post.Media[0])), "two minutes after the last file, not the first");
Assert.AreEqual(clock.Now + TimeSpan.FromMinutes(2), await clock.WaitForDelayAsync(asked, ct), "two minutes after the last file, not the first");
var passes = worker.Passes;
clock.Advance(TimeSpan.FromSeconds(30)); // two minutes after the first file
Assert.AreEqual(first + TimeSpan.FromSeconds(90) + TimeSpan.FromMinutes(2), clock.Pending.Single(), "still settling");
Assert.AreEqual(passes, worker.Passes);
Assert.IsFalse(File.Exists(bed.GeneralCopy(bed.Luca, post.Media[0])));
Assert.IsEmpty(await bed.Db.Exports.ListRunsAsync(ct));
bed.Signal.Signal(urgent: true);
@@ -653,6 +696,44 @@ public sealed class AutoExportWorkerTests
await loop;
}
/// <summary>
/// Files that keep arriving push the settle on, at most a quarter of an hour after the first one (§4.10): with a file
/// every 90 s the pass starts 15 minutes after the first file, not never.
/// </summary>
[TestMethod]
public async Task FilesThatKeepArrivingPostponeThePassAtMostAQuarterOfAnHour()
{
var ct = TestContext.CancellationToken;
GatedClock? clock = null;
await using var bed = await ExportTestBed.CreateAsync(env => env with { Clock = clock = new GatedClock((ManualClock)env.Clock) });
await TurnOnAsync(bed, await bed.GeneralAsync(ct: ct), onlyNew: false, ct);
var worker = Worker(bed, clock);
var loop = worker.RunAsync(ct);
await IdleAsync(bed, worker, clock!, ct);
var asked = clock!.Asked;
var first = clock.Now;
var limit = first + TimeSpan.FromMinutes(15);
var post = await bed.PostAsync(bed.Luca, "q00", 1);
Assert.AreEqual(first + TimeSpan.FromMinutes(2), await clock.WaitForDelayAsync(asked, ct));
for (var i = 1; i <= 9; i++)
{
clock.Advance(TimeSpan.FromSeconds(90));
asked = clock.Asked;
await bed.PostAsync(bed.Luca, $"q{i:00}", i + 1);
var due = await clock.WaitForDelayAsync(asked, ct);
var expected = clock.Now + TimeSpan.FromMinutes(2) < limit ? clock.Now + TimeSpan.FromMinutes(2) : limit;
Assert.AreEqual(expected, due, $"file {i}");
Assert.IsEmpty(await bed.Db.Exports.ListRunsAsync(ct));
}
Assert.AreEqual(limit, clock.Pending.Single(), "the last settle ends at the quarter of an hour");
clock.Advance(limit - clock.Now);
await WaitUntilAsync(() => Task.FromResult(File.Exists(bed.GeneralCopy(bed.Luca, post.Media[0]))), ct);
await worker.StopAsync();
await loop;
}
/// <summary>A file saved while a pass's job is at work is copied by a pass after it: the signal is not lost.</summary>
[TestMethod]
public async Task ASignalDuringAPassIsNotLost()