Merge branch 'review2-p1-fix-import' into claude/owner-review-2-p1

This commit is contained in:
Alby96 committed 2026-10-26 23:40:39 +01:00
commit b8fa04dc28
13 files changed
+181 -25

No files matched your search

+12 -6
View File
@@ -45,7 +45,10 @@ public sealed record PlanTotals(int Sessions, int Photos, int CopyCount, long Co
/// <param name="DefaultTitle">Title the sequence gets when the user types none (a whole folder's name, else its folder name).</param>
/// <param name="IsNew">The session starts a new sequence (false: it continues one imported before).</param>
/// <param name="FirstPath">Card path of the session's first photo (where a merge joins it to the previous session).</param>
/// <param name="MergesInto">Number of the earlier session of the same camera and format it can merge into; null for none.</param>
/// <param name="MergesInto">
/// Number of the earlier session it can merge into (same camera and format; for a whole folder, same format whatever the
/// camera); null for none.
/// </param>
public sealed record PlanSessionRow(int Number, string SessionKey, string? Title, string DefaultTitle, string TimeText, string FramesText,
string SizeText, string CameraText, string TargetText, bool IsNew, string FirstPath, int? MergesInto);
@@ -250,12 +253,15 @@ public static class ImportPlans
};
/// <summary>
/// "28/09/2026 · 18:02 → 20:04". Bidi never mirrors an arrow, so a right-to-left language reads it from its own
/// resource with the arrow pointing from the start to the end in its reading order.
/// "28/09/2026 · 18:02 → 20:04"; one that ends on another day (a whole folder, often) shows both dates:
/// "28/09/2026 18:02 → 06/10/2026 18:00". Bidi never mirrors an arrow, so a right-to-left language reads it from its
/// own resource with the arrow pointing from the start to the end in its reading order.
/// </summary>
private static string TimeText(PlannedSession s) =>
Loc.L(Loc.IsRightToLeft ? "Import.Session.TimeRtl" : "Import.Session.Time", Formatting.Date(s.Start), s.Start.ToString("t", Loc.Culture),
s.End.ToString("t", Loc.Culture));
private static string TimeText(PlannedSession s) => s.End.Date == s.Start.Date
? Loc.L(Loc.IsRightToLeft ? "Import.Session.TimeRtl" : "Import.Session.Time", Formatting.Date(s.Start), s.Start.ToString("t", Loc.Culture),
s.End.ToString("t", Loc.Culture))
: Loc.L(Loc.IsRightToLeft ? "Import.Session.TimeDaysRtl" : "Import.Session.TimeDays", Formatting.Date(s.Start), s.Start.ToString("t", Loc.Culture),
Formatting.Date(s.End), s.End.ToString("t", Loc.Culture));
/// <summary>"3,600 · 2 s": photos and the median interval between them.</summary>
private static string FramesText(PlannedSession s)
@@ -6,8 +6,9 @@ using Chronos.Ui.Mvvm;
namespace Chronos.App.Import;
/// <summary>
/// A session of the plan with its editable title (the sequence title; empty keeps the folder name) and its merge into
/// the earlier session of the same camera (BRIEF §13). Both can change only while the plan is not running.
/// A session of the plan with its editable title (the sequence title; empty keeps the default title) and its merge into
/// the earlier session of the same camera and format, or for a whole folder of the same format (BRIEF §13). Both can
/// change only while the plan is not running.
/// </summary>
public sealed class ImportSessionRowViewModel : ObservableObject
{
+12 -7
View File
@@ -13,10 +13,11 @@ namespace Chronos.App.Import;
/// protocol's resumable chunks and the hash computed while copying; the server checks that hash before it commits the
/// frame, and only then does the photo count as imported. Photos of one plan session share its session key, so the
/// server files them in one sequence — the same one when an interrupted import is started again. A typed session
/// title is set on that sequence once. A file the server refuses (a hash mismatch, a format it rejects) is listed in
/// <see cref="Report"/> and the import goes on (BRIEF §13: errors per file); a failed connection, sign-in or server
/// stops it. A file the server already held counts as a duplicate: the server answers so only for a copy that is not
/// flagged missing or damaged, and a server import never deletes anything from the card.
/// title is set on that sequence once; a whole folder's own name only on a sequence that has no title yet, so a rename
/// made on the server survives the next import of the folder. A file the server refuses (a hash mismatch, a format it
/// rejects) is listed in <see cref="Report"/> and the import goes on (BRIEF §13: errors per file); a failed connection,
/// sign-in or server stops it. A file the server already held counts as a duplicate: the server answers so only for a
/// copy that is not flagged missing or damaged, and a server import never deletes anything from the card.
/// </summary>
public sealed class ServerImportSink(ChronosClient client, string stagingDirectory) : IImportSink
{
@@ -85,16 +86,20 @@ public sealed class ServerImportSink(ChronosClient client, string stagingDirecto
Directory.Delete(folder);
}
if (committed is { Index: >= 0 } && session.Title is { Length: > 0 } title && _titled.Add(committed.SequenceId))
await SetTitleAsync(committed.SequenceId, title, cancellationToken).ConfigureAwait(false);
await SetTitleAsync(committed.SequenceId, title, keepExisting: title == session.DefaultTitle, cancellationToken).ConfigureAwait(false);
}
return results;
}
/// <summary>A refused title leaves the photos imported under the sequence's own name.</summary>
private async Task SetTitleAsync(Guid sequenceId, string title, CancellationToken cancellationToken)
/// <summary>
/// Names the sequence; with <paramref name="keepExisting"/> (the title the user did not type) only one without a
/// title. A refused title leaves the photos imported under the sequence's own name.
/// </summary>
private async Task SetTitleAsync(Guid sequenceId, string title, bool keepExisting, CancellationToken cancellationToken)
{
try
{
if (keepExisting && (await client.GetSequenceAsync(sequenceId, cancellationToken).ConfigureAwait(false)).Title is { Length: > 0 }) return;
await client.UpdateSequenceAsync(sequenceId, new UpdateSequenceRequest(title, null, null, null, null, null), cancellationToken).ConfigureAwait(false);
}
catch (ChronosApiException ex) when (IsRefusal(ex))
+2 -1
View File
@@ -102,13 +102,14 @@
</Style.Triggers>
</Style>
<!-- Up to four digits (gap ≤ 1440) in 56 px: half the usual side padding. -->
<!-- Up to four digits (gap ≤ 1440) in 56 px: half the usual side padding. A disabled box still says why in its tooltip. -->
<Style x:Key="TextBox.Small" TargetType="TextBox" BasedOn="{StaticResource TextBox.Number}">
<Setter Property="Width" Value="56" />
<Setter Property="Height" Value="30" />
<Setter Property="Padding" Value="4,0" />
<Setter Property="Margin" Value="6,0" />
<Setter Property="FlowDirection" Value="LeftToRight" />
<Setter Property="ToolTipService.ShowOnDisabled" Value="True" />
</Style>
<!-- File paths and name templates stay left to right in every language (BRIEF §16). -->
+4 -1
View File
@@ -1134,7 +1134,10 @@ public sealed class ImportViewModel : SectionViewModel
else ApplyPlan();
}
/// <summary>Joins a session to the earlier one of the same camera and format (BRIEF §13: merge in the plan).</summary>
/// <summary>
/// Joins a session to the earlier one of the same camera and format, or for a whole folder of the same format
/// (BRIEF §13: merge in the plan).
/// </summary>
private void Merge(PlanSessionRow row)
{
_splits.Remove(row.FirstPath);