E2: motore delle copie esterne (porta, destinazioni, piano, copia)
Prima metà della tappa E2 «Copie esterne» (#58), parte Core e Data: - porta del lavoro lungo: importazione, copia e ricostruzione mai insieme; - radice /esporta in Docker con mountinfo, controllo delle cartelle con il file di prova, destinazioni con «Esporta questo account» acceso se Alberto non ha mai scelto (decisione del 27/11/2026); - filtro «Copie», segni delle tessere e conteggi dell'account sui soli file dovuti (D3); - percorsi «Come la libreria», segmento dell'account nella cartella generale, 240 caratteri, storia in evidenza; - piano di «Copia in…», un lavoro per destinazione, copia in .part con SHA-256 riletto dal disco, nome libero, mai sovrascrivere, adozione per percorso, pausa della destinazione su prova, spazio e FAT32, attesa fuori dalle sessioni del motore, ripresa e recupero; - .part rimossi solo nelle cartelle degli elementi di lavori non finiti; - «Tolto» e «Superato» (agganci in importazione, scaricamenti, doppioni e ricostruzione), mai ricopiati da soli; - rapporti e testi in italiano, prove del lavoro di copia. Interfaccia, API e composizione restano alla parte successiva. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
213b89a618
commit
a112c92893
41 files changed
+5370
-27
No files matched your search
@@ -1,5 +1,6 @@
|
||||
using Febe.Core.Domain;
|
||||
using Febe.Core.Engine;
|
||||
using Febe.Core.Export;
|
||||
using Febe.Core.Library;
|
||||
using Febe.Core.Storage;
|
||||
|
||||
@@ -545,6 +546,9 @@ public sealed class ImportCopier(ImportEnvironment env)
|
||||
media.State,
|
||||
env.Clock.Now,
|
||||
none).ConfigureAwait(false);
|
||||
|
||||
// The copies of the old file in external folders are now «Superato» (spec §4.10): never copied again by themselves.
|
||||
await ExportSupersession.FileChangedAsync(env.Storage, account.Id, media.Sha256, saved.Sha256, env.Clock.Now, none).ConfigureAwait(false);
|
||||
await context.Ingest.TryAppendJournalAsync(entry.Id, none).ConfigureAwait(false);
|
||||
if (entry.InstagramId is null && string.IsNullOrWhiteSpace(entry.Code) && !string.Equals(oldRelative, saved.RelativePath, StringComparison.Ordinal))
|
||||
{
|
||||
|
||||
@@ -58,6 +58,12 @@ public sealed record ImportEnvironment
|
||||
/// <summary>Reading, hashing and deleting source files.</summary>
|
||||
public IImportFileSystem FileSystem { get; init; } = ImportFileSystem.Instance;
|
||||
|
||||
/// <summary>
|
||||
/// The gate shared with the export and the rebuild (spec §4.10: they never run together). Null: no other long work
|
||||
/// to keep out (tests, the import alone).
|
||||
/// </summary>
|
||||
public LongWorkGate? Gate { get; init; }
|
||||
|
||||
/// <summary>Files analysed at the same time (hashing and decoding).</summary>
|
||||
public int Parallelism { get; init; } = Math.Clamp(Environment.ProcessorCount, 1, 4);
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Diagnostics;
|
||||
using Febe.Core.Abstractions;
|
||||
using Febe.Core.Domain;
|
||||
using Febe.Core.Storage;
|
||||
|
||||
@@ -283,6 +284,12 @@ public sealed class ImportService : IAsyncDisposable
|
||||
{
|
||||
throw new InvalidOperationException("C'è già un'importazione al lavoro: aspetta che finisca o interrompila.");
|
||||
}
|
||||
|
||||
// Checked up front too, so a refused start records nothing; StartJob takes the gate for real.
|
||||
if (_env.Gate?.Busy is { } busy)
|
||||
{
|
||||
throw new InvalidOperationException(LongWorkGate.BusyMessage(LongWorkKind.Import, busy));
|
||||
}
|
||||
}
|
||||
|
||||
private void StartJob(long runId, ImportPhase phase, Func<IProgress<ImportProgress>, CancellationToken, Task> work)
|
||||
@@ -294,6 +301,12 @@ public sealed class ImportService : IAsyncDisposable
|
||||
throw new InvalidOperationException("C'è già un'importazione al lavoro: aspetta che finisca o interrompila.");
|
||||
}
|
||||
|
||||
IDisposable? lease = null;
|
||||
if (_env.Gate is { } gate && !gate.TryEnter(LongWorkKind.Import, out lease, out var busy))
|
||||
{
|
||||
throw new InvalidOperationException(LongWorkGate.BusyMessage(LongWorkKind.Import, busy!.Value));
|
||||
}
|
||||
|
||||
_job?.Cancellation.Dispose();
|
||||
var cancellation = new CancellationTokenSource();
|
||||
var reporter = new Reporter(this);
|
||||
@@ -322,6 +335,10 @@ public sealed class ImportService : IAsyncDisposable
|
||||
{
|
||||
// The database is closing: nothing to publish.
|
||||
}
|
||||
finally
|
||||
{
|
||||
lease?.Dispose();
|
||||
}
|
||||
}
|
||||
});
|
||||
_job = new Job(runId, phase, cancellation, task);
|
||||
|
||||
Reference in new issue
Block a user