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

+11 -4
View File
@@ -27,6 +27,12 @@ public interface IImportSink
/// <summary>Folder for verified copies, on the destination volume so commits are renames.</summary>
string StagingDirectory { get; }
/// <summary>
/// True when <see cref="StagingDirectory"/> lies on this PC rather than at the destination (a server import stages its
/// copies in this PC's cache folder): a full disk or a refused write while staging then concerns this PC.
/// </summary>
bool StagesOnThisPc => false;
/// <summary>Moves staged files of one session into place; returns one result per file, in order. Files it does
/// not move stay where they are and the executor deletes them.</summary>
Task<IReadOnlyList<SinkCommit>> CommitAsync(PlannedSession session, IReadOnlyList<StagedFile> files, CancellationToken cancellationToken);
@@ -138,7 +144,7 @@ public sealed class ImportExecutor(ImportPlan plan, IImportSink sink)
}
Log.Warning("import", $"Copy of {item.SourcePath} failed", ex);
failed++;
results.Add(new ImportItemResult(session, item, ImportItemStatus.Failed, null, null, FailureText(ex)));
results.Add(new ImportItemResult(session, item, ImportItemStatus.Failed, null, null, FailureText(ex, sink.StagesOnThisPc)));
}
}
await FlushAsync().ConfigureAwait(false);
@@ -148,13 +154,14 @@ public sealed class ImportExecutor(ImportPlan plan, IImportSink sink)
/// <summary>
/// Why one photo was not copied, as one localized sentence (BRIEF §0.2 rule 6): the Import screen lists it beside the
/// photo and the import job writes it to its log. The executor's own checks say what they found; the operating
/// system's text, technical English, goes to the application log only.
/// system's text, technical English, goes to the application log only. A full disk is the staging folder's: the
/// destination's, or this PC's when the sink stages there (<paramref name="stagesOnThisPc"/>).
/// </summary>
internal static string FailureText(Exception ex) => ex switch
internal static string FailureText(Exception ex, bool stagesOnThisPc = false) => ex switch
{
// Already one localized sentence each.
ImportSourceChangedException or CopyVerificationException => ex.Message,
IOException { HResult: DiskFull or HandleDiskFull } => Loc.L("Import.Failed.Full"),
IOException { HResult: DiskFull or HandleDiskFull } => Loc.L(stagesOnThisPc ? "Import.Failed.CacheFull" : "Import.Failed.Full"),
UnauthorizedAccessException => Loc.L("Import.Failed.PhotoAccess"),
_ => Loc.L("Import.Failed.Photo"),
};