fix(import): staging failures of a server import name this PC, failed jobs show catalog sentences

A server import stages its copies in this PC's cache folder, yet a full disk
there read 'The destination is full.' beside every photo, and a refused
write 'Titano may not write to the destination.', which sent the user to
the server. IImportSink.StagesOnThisPc (true for ServerImportSink) selects
Import.Failed.CacheFull and Import.Failed.CacheAccess instead.

A failed archive import job showed the job engine's raw text (SQLite, file
system or framework English) as the Import screen's line. ImportFailures.Job
keeps the archive engine's own localized sentences and shows 'The import
stopped before the end.' for anything else; the raw text stays in the
tooltip and the logs.

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 19:00:51 +00:00
1 parent 59d49f16af
commit e97b0e4f84
9 files changed
+100 -9

No files matched your search

@@ -49,6 +49,47 @@ public sealed class ImportFailuresTests
Assert.Equal(Loc.L("Server.Error.Untrusted"), ImportFailures.Stop(new UntrustedCertificateException("AB:CD"), Card));
}
[Test]
public void AServerImportStoppedOnThisPcNamesItsCacheFolderNotTheServer()
{
// The server import stages its copies in this PC's cache folder; the server answers for its own space and rights.
const string Card = "EOS R5 · card A";
using var client = new TitanoClient(new Uri("https://nas.local:8443/"), new CertificatePinning([]), "tests");
var staging = Path.Combine(Path.GetTempPath(), "titano-server-import");
Assert.True(((IImportSink)new ServerImportSink(client, staging)).StagesOnThisPc);
Assert.Equal("The drive of this PC's cache folder is full.",
ImportFailures.Stop(new IOException("There is not enough space on the disk.", unchecked((int)0x80070070)), Card, stagesOnThisPc: true));
Assert.Equal("Titano may not write to this PC's cache folder.",
ImportFailures.Stop(new UnauthorizedAccessException(@"Access to the path 'C:\Users\me\AppData\Local\Titano\cache\server-import' is denied."), Card,
stagesOnThisPc: true));
Assert.Equal("EOS R5 · card A is no longer available.", ImportFailures.Stop(new ImportSourceUnavailableException(@"E:\"), Card, stagesOnThisPc: true));
Assert.Equal("The import stopped before the end.", ImportFailures.Stop(new IOException("The specified network name is no longer available."), Card, stagesOnThisPc: true));
Assert.Equal(Loc.L("Server.Error.Unreachable"), ImportFailures.Stop(new HttpRequestException("No such host is known."), Card, stagesOnThisPc: true));
}
[Test]
public void AFailedImportJobShowsOnlyTheArchivesOwnSentences()
{
// The job engine keeps the text of what stopped the job: the archive's own failures are already catalog sentences.
Assert.Equal("The archive D:\\Shoots is offline.", ImportFailures.Job(new ArchiveOfflineException(@"D:\Shoots", ArchiveAvailability.Offline).Message));
Assert.Equal("The archive D:\\Shoots is read-only.", ImportFailures.Job(new ArchiveOfflineException(@"D:\Shoots", ArchiveAvailability.ReadOnly).Message));
Assert.Equal("The card or folder E:\\ is no longer available.", ImportFailures.Job(new ImportSourceUnavailableException(@"E:\").Message));
var busy = new LeaseUnavailableException("settings", new LeaseRecord("t", "Titano Server (nas)", "nas", 42, DateTimeOffset.UnixEpoch, DateTimeOffset.UnixEpoch));
Assert.Equal(busy.Message, ImportFailures.Job(busy.Message));
var newer = new NewerFormatException(Path.Combine(Path.GetTempPath(), "archive.json"), 3);
Assert.Equal("archive.json was written by a newer Titano (format 3).", ImportFailures.Job(newer.Message));
Assert.Equal("IMG_0001.CR3 could not be added to the sequence.", ImportFailures.Job(Loc.L("Archive.Error.DuplicateLost", "IMG_0001.CR3")));
// A database, framework or system text reads as the catalog's sentence; the tooltip keeps it.
Assert.Equal("The import stopped before the end.", ImportFailures.Job("database is locked: no write lock within 30 s"));
Assert.Equal("The import stopped before the end.",
ImportFailures.Job(@"The process cannot access the file 'D:\Shoots\2026\IMG_0001.CR3' because it is being used by another process."));
Assert.Equal("The import stopped before the end.", ImportFailures.Job("There is not enough space on the disk. : 'D:\\Shoots\\.titano\\journal'"));
Assert.Equal("The import stopped before the end.", ImportFailures.Job($"Sequence {Guid.Empty} is not indexed."));
Assert.Equal("The import stopped before the end.", ImportFailures.Job(null));
Assert.Equal("The import stopped before the end.", ImportFailures.Job(string.Empty));
}
[Test]
public void APlanningFailureNamesTheSource()
{