E5: «Riconosci» va avanti su un file illeggibile e non tocca nulla

Un file della cartella che non si legge (aperto da un altro programma,
senza permessi) rende «Non riuscito» solo il suo elemento: prima fermava
tutto il lavoro, e «Riprendi» si fermava sempre lì. «Annulla» e il
riavvio non tolgono più i .part nelle cartelle di un «Riconosci», come
dice la specifica. Una riga orfana «Superato» ricollegata diventa
«Copiato», come dice l'elemento; una riga orfana «Tolto» resta «Tolto»
anche per il file, come già per i fotogrammi (risposta 51). I nomi
numerati si guardano tutti fino a «nome (50)», anche dopo un buco. I
byte della libreria di un «Riconosci», che non scrive, non contano più
per la prova della cartella: una prova per gruppo di file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-12-04 19:51:12 +01:00
1 parent 309f4d0402
commit 11e9dd276c
7 files changed
+317 -26

No files matched your search

+31 -11
View File
@@ -88,8 +88,11 @@ public sealed partial class ExportCopier
return await FinishAsync(item with { State = ExportItemState.Skipped, Note = ExportText.Notes.Removed, CopyId = copied[0].Id, LastError = null }, library.Bytes, copied[0].RelativePath).ConfigureAwait(false);
}
// Answer 51: a file whose newest copy here is «Tolto» is never recognised, even if its file came back identical.
if (await exports.FindLatestCopyAnyFormAsync(destination.Id, account, sha, ct).ConfigureAwait(false) is { State: ExportCopyState.Removed } removed)
// Answer 51: a file whose newest copy here is «Tolto» is never recognised, even if its file came back identical;
// when the account has no row of it, the newest orphan row (account removed) decides, as for a frame.
var latest = await exports.FindLatestCopyAnyFormAsync(destination.Id, account, sha, ct).ConfigureAwait(false)
?? await exports.FindLatestOrphanCopyAnyFormAsync(destination.Id, sha, ct).ConfigureAwait(false);
if (latest is { State: ExportCopyState.Removed } removed)
{
return await FinishAsync(item with { State = ExportItemState.Skipped, Note = ExportText.Notes.Removed, CopyId = removed.Id, LastError = null }, library.Bytes, removed.RelativePath).ConfigureAwait(false);
}
@@ -140,6 +143,7 @@ public sealed partial class ExportCopier
return await NotFoundAsync(x, item, library.Bytes, ct).ConfigureAwait(false);
}
var unreadable = new List<Exception>();
foreach (var (format, paths) in forms)
{
MediaConversionResult? conversion = null;
@@ -178,7 +182,7 @@ public sealed partial class ExportCopier
var identity = new ExportCopyIdentity(destination.Id, account, sha, output.Variant, output.Format, null);
var current = await exports.FindCurrentCopyAsync(identity, ct).ConfigureAwait(false);
var failed = current is { State: ExportCopyState.Failed } ? current : null;
var result = await TryAdoptAsync(x, item, new FileContext(library, identity), output, failed, paths, ExportItemState.Adopted, ct).ConfigureAwait(false);
var result = await TryAdoptAsync(x, item, new FileContext(library, identity), output, failed, paths, ExportItemState.Adopted, ct, unreadable).ConfigureAwait(false);
if (result is not null)
{
if (result.State is ExportItemState.Adopted or ExportItemState.AlreadyCopied)
@@ -192,6 +196,11 @@ public sealed partial class ExportCopier
}
}
if (await UnreadableAsync(item, library.Bytes, unreadable) is { } failedRead)
{
return failedRead;
}
// The report shows the path where another file is (the first one looked at).
var different = forms[0].Paths[0];
return await FinishAsync(item with { State = ExportItemState.Skipped, Note = ExportText.Notes.Different, RelativePath = different, LastError = null }, library.Bytes, different).ConfigureAwait(false);
@@ -261,6 +270,7 @@ public sealed partial class ExportCopier
}
// The bytes a row of this very frame recorded at the path: compared without taking the frame again.
var unreadable = new List<Exception>();
var others = new List<string>();
foreach (var path in paths)
{
@@ -268,7 +278,7 @@ public sealed partial class ExportCopier
&& string.Equals(holder.SourceSha256, library.Sha256, StringComparison.Ordinal) && holder.Format == format && holder.FrameAt == at)
{
var known = new Output(ExportVariant.Frame, format, at, extension, null, bytes, copySha, null, []);
if (await TryAdoptAsync(x, item, file, known, failed, [path], ExportItemState.Adopted, ct).ConfigureAwait(false) is { } adopted)
if (await TryAdoptAsync(x, item, file, known, failed, [path], ExportItemState.Adopted, ct, unreadable).ConfigureAwait(false) is { } adopted)
{
return adopted;
}
@@ -286,12 +296,17 @@ public sealed partial class ExportCopier
return await FinishAsync(item with { State = ExportItemState.Skipped, Note = ExportText.Notes.FrameNotAvailable, LastError = null }, 0, null).ConfigureAwait(false);
}
if (await TryAdoptAsync(x, item, file, taken, failed, others, ExportItemState.Adopted, ct).ConfigureAwait(false) is { } adopted)
if (await TryAdoptAsync(x, item, file, taken, failed, others, ExportItemState.Adopted, ct, unreadable).ConfigureAwait(false) is { } adopted)
{
return adopted;
}
}
if (await UnreadableAsync(item, 0, unreadable) is { } failedRead)
{
return failedRead;
}
return await FinishAsync(item with { State = ExportItemState.Skipped, Note = ExportText.Notes.Different, RelativePath = paths[0], LastError = null }, 0, paths[0]).ConfigureAwait(false);
}
@@ -310,8 +325,17 @@ public sealed partial class ExportCopier
}
/// <summary>
/// The files of the destination at <paramref name="planned"/> and at its numbered names («nome (2)» … «nome (50)»,
/// numbered as the writer numbers them), these until the first one that is not there.
/// A file of the destination that could not be read was not adopted: the item is «Non riuscito» with the error (no copy
/// row), so the run goes on to the next file and «Riconosci» can be run again. Null when every file was read.
/// </summary>
private async Task<ItemResult?> UnreadableAsync(ExportItem item, long bytes, List<Exception> unreadable) =>
unreadable.Count == 0
? null
: await FinishAsync(item with { State = ExportItemState.Failed, Note = null, LastError = ExportText.ErrorText(unreadable[0]) }, bytes, null).ConfigureAwait(false);
/// <summary>
/// The files of the destination at <paramref name="planned"/> and at all its numbered names («nome (2)» … «nome (50)»,
/// numbered as the writer numbers them): a gap (a copy deleted in the middle) does not hide the names after it.
/// </summary>
private List<string> PresentNames(string root, string planned, string? keepSuffix)
{
@@ -332,10 +356,6 @@ public sealed partial class ExportCopier
{
found.Add(name);
}
else if (attempt > 1)
{
break; // the writer takes the first free name: nothing of ours after it
}
}
return found;