fix(import): say what a proxy's reply means instead of its English reason phrase
A reply that is not the server's JSON (a reverse proxy's 502 page while the container restarts, its 413 for a large body, a bare 500) reached the Import screen as the HTTP reason phrase, in English, beside every photo. ErrorText now uses an ApiError's message only when the server wrote it (a code that is not TitanoClient's http_<status> fallback) and otherwise says what the status means: too large, rate limited, not answering (gateway and timeout statuses) or a server error. A card file that cannot be read while planning is listed with the executor's catalog sentence instead of the system's text and full path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
6 files changed
+97
-6
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;
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user