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:
11 files changed
+132
-17
No files matched your search
@@ -1,5 +1,6 @@
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using Titano.App.Import;
|
||||
using Titano.Core.Import;
|
||||
using Titano.Core.Localization;
|
||||
@@ -111,7 +112,7 @@ public sealed class ImportFlowTests(TestContext context)
|
||||
Assert.Equal(16, plan.CopyCount);
|
||||
|
||||
var reports = new List<ImportProgress>();
|
||||
var outcome = await LocalImport.RunAsync(plan, new FolderImportSink(target), verify: true, new Progress(reports), context.Cancellation);
|
||||
var outcome = await LocalImport.RunAsync(plan, new FolderImportSink(target), "EOS R5 · card A", verify: true, new Progress(reports), context.Cancellation);
|
||||
Assert.Equal(16, outcome.Copied);
|
||||
Assert.True(outcome.IsComplete);
|
||||
Assert.True(outcome.Verified);
|
||||
@@ -120,7 +121,7 @@ public sealed class ImportFlowTests(TestContext context)
|
||||
Assert.FileExists(Path.Combine(target, folder, name));
|
||||
|
||||
var again = await LocalImport.RunAsync(await destination.PlanAsync(card, new ImportChoices().ToOptions(), null, null, context.Cancellation),
|
||||
new FolderImportSink(target), verify: true, null, context.Cancellation);
|
||||
new FolderImportSink(target), "EOS R5 · card A", verify: true, null, context.Cancellation);
|
||||
Assert.Equal(0, again.Copied);
|
||||
Assert.Equal(16, again.Duplicates);
|
||||
Assert.False(new CardActions(ImportDestinationKind.Folder, false, true, true, outcome, null, null).CanCheck);
|
||||
@@ -164,6 +165,21 @@ public sealed class ImportFlowTests(TestContext context)
|
||||
outcome.Failures);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ARunTheServerStopsListsEveryPhotoLeftWithASentenceNotTheExceptionText()
|
||||
{
|
||||
Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
|
||||
var card = Card(context.CreateTempDirectory("card"), 8, Start);
|
||||
var staging = context.CreateTempDirectory("staging");
|
||||
var plan = await new UnindexedDestination(ImportDestinationKind.Server, staging).PlanAsync(card, new ImportChoices().ToOptions(), null, null,
|
||||
context.Cancellation);
|
||||
|
||||
var outcome = await LocalImport.RunAsync(plan, new UnreachableSink(staging), "EOS R5 · card A", verify: true, null, context.Cancellation);
|
||||
Assert.Equal(0, outcome.Imported);
|
||||
Assert.Equal(8, outcome.Failures.Count);
|
||||
Assert.True(outcome.Failures.All(f => f.Message == Loc.L("Server.Error.Unreachable")), "the stop reason is the catalog's, never the exception's text");
|
||||
}
|
||||
|
||||
private async Task WaitDoneAsync(TitanoDatabase db, Guid jobId)
|
||||
{
|
||||
var until = DateTime.UtcNow.AddSeconds(60);
|
||||
@@ -177,6 +193,15 @@ public sealed class ImportFlowTests(TestContext context)
|
||||
Assert.Fail("The import job did not finish");
|
||||
}
|
||||
|
||||
/// <summary>A server destination whose connection is gone: every commit fails as the HTTP stack reports it.</summary>
|
||||
private sealed class UnreachableSink(string staging) : IImportSink
|
||||
{
|
||||
public string StagingDirectory { get; } = staging;
|
||||
|
||||
public Task<IReadOnlyList<SinkCommit>> CommitAsync(PlannedSession session, IReadOnlyList<StagedFile> files, CancellationToken cancellationToken) =>
|
||||
throw new HttpRequestException("An error occurred while sending the request.");
|
||||
}
|
||||
|
||||
/// <summary>Collects reports synchronously (System.Progress posts to the thread pool).</summary>
|
||||
private sealed class Progress(List<ImportProgress> into) : IProgress<ImportProgress>
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user