fix(import): say why a photo was not copied with a catalog sentence

A photo the executor could not copy now carries one localized sentence
(ImportExecutor.FailureText: its own checks, a full destination, access
denied, else "The photo could not be read or copied.") on the Import
screen and in the import job's log. The photos a stopped folder or
server import never reached show the stop's cause (ImportFailures.Stop:
the server's own sentence, not answering, untrusted certificate, card
gone, destination full or not writable), and a failed index check reads
"The index could not be read or written.". A refusal without words
reads as the catalog's sentence. The system's text stays in the log.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-12 15:53:49 +00:00
1 parent 32a0e9bbc1
commit 5cf918ed66
11 files changed
+132 -17

No files matched your search

@@ -1,5 +1,6 @@
using Titano.Core.Archiving;
using Titano.Core.Import;
using Titano.Core.Localization;
using Titano.Core.Tests.Archiving;
using Titano.Testing;
using static Titano.Core.Tests.Import.ImportTestKit;
@@ -141,6 +142,41 @@ public sealed class ImportExecutorTests(TestContext context)
Assert.Equal(19, final.Copied);
Assert.Equal(1, final.Failed);
Assert.Equal(plan.Sessions[0].Items[5].SourcePath, failed.Single().Item.SourcePath);
Assert.Equal(Loc.L("Archive.Error.SourceChanged", plan.Sessions[0].Items[5].SourcePath), failed.Single().Error);
}
[Test]
public async Task ACopyTheSystemRefusesFailsAloneWithACatalogSentence()
{
var card = Card(10);
var destination = context.CreateTempDirectory("dest");
var plan = await PlanAsync(card, destination);
var sink = new FolderImportSink(destination);
// A folder squats the staging name of the fourth copy: creating that copy fails with the system's own text.
var item = plan.Sessions[0].Items[3];
Directory.CreateDirectory(Path.Combine(sink.StagingDirectory, $"{plan.Id:N}-{3:D6}{Path.GetExtension(item.FileName)}"));
var failed = new List<ImportItemResult>();
var final = await RunAsync(plan, sink, committed: b =>
{
failed.AddRange(b.Results.Where(r => r.Status == ImportItemStatus.Failed));
return ValueTask.CompletedTask;
});
Assert.Equal(9, final.Copied);
Assert.Equal(item.SourcePath, failed.Single().Item.SourcePath);
Assert.Contains(failed.Single().Error, new[] { Loc.L("Import.Failed.Photo"), Loc.L("Import.Failed.PhotoAccess") });
}
[Test]
public void AFailedCopySaysWhyInOneLocalizedSentence()
{
Assert.Equal(Loc.L("Import.Failed.Full"), ImportExecutor.FailureText(new IOException("There is not enough space on the disk.", unchecked((int)0x80070070))));
Assert.Equal(Loc.L("Import.Failed.Full"), ImportExecutor.FailureText(new IOException("The disk is full.", unchecked((int)0x80070027))));
Assert.Equal(Loc.L("Import.Failed.PhotoAccess"), ImportExecutor.FailureText(new UnauthorizedAccessException(@"Access to the path 'E:\DCIM\IMG_0001.CR3' is denied.")));
Assert.Equal(Loc.L("Import.Failed.Photo"), ImportExecutor.FailureText(new IOException("The semaphore timeout period has expired.")));
Assert.Equal(Loc.L("Import.Failed.Photo"), ImportExecutor.FailureText(new FileNotFoundException(@"Could not find file 'E:\DCIM\IMG_0001.CR3'.")));
// The executor's own checks are one sentence each already.
Assert.Equal(Loc.L("Archive.Error.CopyMismatch", "IMG_0001.CR3"), ImportExecutor.FailureText(new CopyVerificationException("/staging/IMG_0001.CR3")));
Assert.Equal(Loc.L("Archive.Error.SourceChanged", "DCIM/IMG_0001.CR3"), ImportExecutor.FailureText(new ImportSourceChangedException("DCIM/IMG_0001.CR3")));
}
[Test]