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:
1 parent
31cfdac051
commit
736d241a38
18 files changed
+3124
-12
No files matched your search
@@ -1,3 +1,4 @@
|
||||
using System.Globalization;
|
||||
using Febe.Core.Domain;
|
||||
using Febe.Core.Export;
|
||||
using Febe.Core.Storage;
|
||||
@@ -896,10 +897,14 @@ internal sealed class ExportStore(FebeDatabase db) : IExportStore
|
||||
WHERE source_sha256 IN ({shaList}) AND destination_id = @d AND account_id IS NOT NULL AND variant = 'Whole' AND format = 'Original'
|
||||
""";
|
||||
|
||||
/// <summary>The rows of a destination superseded or removed in favour of some files (ix_export_copy_superseded_by).</summary>
|
||||
/// <summary>
|
||||
/// The rows of a destination superseded or removed in favour of some files (ix_export_copy_superseded_by). <c>+state</c>
|
||||
/// keeps the planner off ix_export_copy_destination, which without statistics it took to read every Superseded and
|
||||
/// Removed copy of the destination for each chunk of SHA-256.
|
||||
/// </summary>
|
||||
internal static string ReplacedStatesSql(string shaList) => $"""
|
||||
SELECT account_id, superseded_by_sha256, state, id FROM export_copy
|
||||
WHERE superseded_by_sha256 IN ({shaList}) AND destination_id = @d AND account_id IS NOT NULL AND state IN ('Superseded', 'Removed')
|
||||
WHERE superseded_by_sha256 IN ({shaList}) AND destination_id = @d AND account_id IS NOT NULL AND +state IN ('Superseded', 'Removed')
|
||||
""";
|
||||
|
||||
private const string CandidateColumns =
|
||||
@@ -1040,10 +1045,18 @@ internal sealed class ExportStore(FebeDatabase db) : IExportStore
|
||||
var changed = 0;
|
||||
foreach (var chunk in copyIds.Distinct().Chunk(IdChunk))
|
||||
{
|
||||
var command = w.Command(string.Empty).With("@at", Sql.Time(at));
|
||||
var list = command.AddList("i", chunk);
|
||||
// The write context keeps one prepared command per SQL text: the text names its parameters, so a
|
||||
// second chunk of the same size reuses the command with new values (one built on an empty text and
|
||||
// filled in afterwards would be the first chunk's command again, its parameters still there).
|
||||
var names = string.Join(", ", chunk.Select((_, i) => string.Create(CultureInfo.InvariantCulture, $"@i{i}")));
|
||||
// A Superseded row keeps the SHA-256 of the file that replaced it: still never copied again by itself.
|
||||
command.CommandText = $"UPDATE export_copy SET state = 'Removed', state_changed_at = @at WHERE id IN ({list}) AND state IN ('Copied', 'Superseded')";
|
||||
var command = w.Command($"UPDATE export_copy SET state = 'Removed', state_changed_at = @at WHERE id IN ({names}) AND state IN ('Copied', 'Superseded')")
|
||||
.With("@at", Sql.Time(at));
|
||||
for (var i = 0; i < chunk.Length; i++)
|
||||
{
|
||||
command.With(string.Create(CultureInfo.InvariantCulture, $"@i{i}"), chunk[i]);
|
||||
}
|
||||
|
||||
changed += command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user