E2: prove del motore, dell'archivio e del servizio delle copie

Le prove della tappa E2 (WP5a) coprono il montaggio di /esporta, la
radice, il controllo delle cartelle, le destinazioni, i percorsi, la
copia, gli stati «Tolto» e «Superato», lo stesso post in due account,
il lavoro in sottofondo (interrompi, riprendi, annulla, riavvio, porta
condivisa con importazione e ricostruzione, sessione del motore,
interruttore dell'account, Docker senza montaggio) e il filtro «Copie».
Si appoggiano a un banco comune con falsi per disco, sessione, montaggi
e file system, senza permessi dei file, così girano anche da root.

Le prove hanno trovato due difetti, corretti:
- MarkCopiesRemovedAsync riusava il comando in cache del primo blocco
  di 900 id: «Controlla le copie» falliva con più di 900 file mancanti
  in una pagina.
- ReplacedStatesSql senza statistiche leggeva tutte le copie tolte o
  superate della destinazione: «+state» la tiene sul suo indice.

Il controllo delle cartelle accetta una scrittura di prova sostituibile,
per provare il guasto della sonda senza permessi.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-27 13:28:20 +01:00
1 parent 31cfdac051
commit 736d241a38
18 files changed
+3124 -12

No files matched your search

+4 -1
View File
@@ -49,6 +49,9 @@ public sealed record ExportEnvironment
/// <summary>Time allowed to a check of a destination folder (a disconnected share must not block).</summary>
public TimeSpan FolderCheckTimeout { get; init; } = TimeSpan.FromSeconds(10);
/// <summary>Writes the probe file of a folder check (a seam: tests make it fail or hang); null: the real file.</summary>
public Action<string>? WriteProbe { get; init; }
/// <summary>How often a waiting job looks whether the engine session ended.</summary>
public TimeSpan SessionPoll { get; init; } = TimeSpan.FromSeconds(5);
@@ -59,7 +62,7 @@ public sealed record ExportEnvironment
public long GroupBytes { get; init; } = 1L << 30;
/// <summary>The checker of destination folders of this environment.</summary>
public ExportFolderCheck CreateFolderCheck() => new(Root.Mounts, FolderCheckTimeout);
public ExportFolderCheck CreateFolderCheck() => new(Root.Mounts, FolderCheckTimeout, WriteProbe);
/// <summary>The protected folders now (Data, library, account folders, <c>/importa</c>) and the extra ones.</summary>
public Task<ExportFolderContext> FolderContextAsync(IReadOnlyList<ProtectedFolder>? extra, CancellationToken ct) =>
+16 -5
View File
@@ -107,13 +107,19 @@ public sealed class ExportFolderException : IOException
/// looked for, read-only. Everything that touches the disk runs in the background with a timeout (10 s by default): a
/// disconnected share never blocks the caller.
/// </summary>
public sealed class ExportFolderCheck(IExportMounts mounts, TimeSpan? timeout = null)
/// <param name="mounts">The mount table (the root of a file system is refused).</param>
/// <param name="timeout">Time allowed to the checks on disk; 10 s when null.</param>
/// <param name="writeProbe">
/// Writes the probe file at the full path given (a seam: tests make it fail or hang); null writes «Febe» in a new file.
/// </param>
public sealed class ExportFolderCheck(IExportMounts mounts, TimeSpan? timeout = null, Action<string>? writeProbe = null)
{
/// <summary>Prefix of the probe file (a temporary file of <see cref="SafeFileWriter"/>: <c>.febe-prova-*.part</c>).</summary>
public const string ProbePrefix = SafeFileWriter.TempPrefix + "prova-";
private readonly IExportMounts _mounts = mounts ?? throw new ArgumentNullException(nameof(mounts));
private readonly TimeSpan _timeout = timeout ?? TimeSpan.FromSeconds(10);
private readonly Action<string> _writeProbe = writeProbe ?? WriteProbeFile;
/// <summary>A new probe file name: <c>.febe-prova-&lt;12 hex&gt;.part</c>.</summary>
public static string NewProbeName() => ProbePrefix + Guid.NewGuid().ToString("N")[..12] + SafeFileWriter.TempSuffix;
@@ -290,7 +296,7 @@ public sealed class ExportFolderCheck(IExportMounts mounts, TimeSpan? timeout =
/// parents of each protected folder (the candidate contains it, or is it) and, for each parent of the candidate, at the
/// same relative path under each protected folder (the candidate is inside it).
/// </summary>
private static ExportFolderVerdict ProbeIdentity(string full, string shown, IReadOnlyList<ProtectedFolder> protectedFolders)
private ExportFolderVerdict ProbeIdentity(string full, string shown, IReadOnlyList<ProtectedFolder> protectedFolders)
{
var name = NewProbeName();
var probe = Path.Combine(full, name);
@@ -298,9 +304,7 @@ public sealed class ExportFolderCheck(IExportMounts mounts, TimeSpan? timeout =
{
try
{
using var stream = new FileStream(probe, FileMode.CreateNew, FileAccess.Write, FileShare.None);
stream.Write("Febe"u8);
stream.Flush(flushToDisk: true);
_writeProbe(probe);
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
{
@@ -352,6 +356,13 @@ public sealed class ExportFolderCheck(IExportMounts mounts, TimeSpan? timeout =
}
}
private static void WriteProbeFile(string path)
{
using var stream = new FileStream(path, FileMode.CreateNew, FileAccess.Write, FileShare.None);
stream.Write("Febe"u8);
stream.Flush(flushToDisk: true);
}
private static bool Exists(string path)
{
try