merge: desktop section fixes (V-0, V-12, V-13, V-14)

Merge branch fix2/desktop-sections into the verification branch.

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 16:56:44 +00:00
commit acd51baa31
23 files changed
+609 -75

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]
@@ -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;
@@ -35,6 +36,25 @@ public sealed class ImportPlannerTests(TestContext context)
Assert.Empty(plan.Problems);
}
[Test]
public void AFileThatCannotBeReadIsAProblemWithOneLocalizedSentence()
{
var card = context.CreateTempDirectory("card");
TestPhotos.WriteSeries(Path.Combine(card, "DCIM", "100CANON"), Start, 3, Interval);
var files = CardScanner.Find(card, includeSubfolders: true);
// A photo leaves the card between listing and reading; another name is a folder the system refuses to read as a file.
File.Delete(Path.Combine(card, files[1].RelativePath));
Directory.CreateDirectory(Path.Combine(card, "DCIM", "100CANON", "IMG_9999.JPG"));
var problems = new List<ImportProblem>();
var photos = CardScanner.ReadMetadata(card, [.. files, new CardFile("DCIM/100CANON/IMG_9999.JPG", 0, Start)], problems);
Assert.Equal(2, photos.Count);
Assert.SequenceEqual([files[1].RelativePath, "DCIM/100CANON/IMG_9999.JPG"], problems.Select(p => p.RelativePath));
Assert.Equal(Loc.L("Import.Failed.Photo"), problems[0].Message);
Assert.Contains(problems[1].Message, new[] { Loc.L("Import.Failed.Photo"), Loc.L("Import.Failed.PhotoAccess") });
Assert.False(problems.Any(p => p.Message.Contains(card, StringComparison.Ordinal)), "the system's text, with the card's path, stays in the log");
}
[Test]
public async Task AFlatFolderIncludesSubfoldersOnlyWhenAsked()
{