feat(import): import a whole folder as one sequence per format
Owner review 2, R9: Import › Folder… gains a "Group" choice for picked folders: Sessions (as before) or Whole folder. A whole folder, with its subfolders when Subfolders is on, becomes one sequence per file format; camera bodies and pauses are ignored, while RAW+JPEG of the same shots stays two sequences so no frame is ever doubled. Only the user's splits break it, and Merge joins a split part back. The planner implements it (ImportOptions.Grouping, Core, Linux-tested): the session key is "folder-" plus a hash of this PC's name, the full path and the format, so an interrupted or repeated import continues the same sequence; the default title is the folder's name. The plan shows one row per format with the format and the number of cameras. Cards and drives always import by sessions; the choice is not part of a card profile and a folder starts on Sessions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5209579631
commit
445dfd41a3
14 files changed
+419
-26
No files matched your search
@@ -15,13 +15,18 @@ public enum ImportDestinationKind
|
||||
|
||||
/// <summary>
|
||||
/// The Import form (Import.html): scan, sessions, names, duplicates and after-import choices. Remembered per card as
|
||||
/// its <see cref="CardProfile"/>; a session gap of 0 minutes in a profile means "do not split into sessions".
|
||||
/// its <see cref="CardProfile"/>; a session gap of 0 minutes in a profile means "do not split into sessions". The
|
||||
/// grouping is not in a profile: a card always imports by sessions, and a picked folder starts with them.
|
||||
/// </summary>
|
||||
public sealed record ImportChoices
|
||||
{
|
||||
public ImportDestinationKind Destination { get; init; } = ImportDestinationKind.Archive;
|
||||
public string? FolderPath { get; init; }
|
||||
public bool IncludeSubfolders { get; init; } = true;
|
||||
|
||||
/// <summary>"Group" (a picked folder only): its sessions, or the whole folder as one sequence per format.</summary>
|
||||
public ImportGrouping Grouping { get; init; } = ImportGrouping.Sessions;
|
||||
|
||||
public bool SplitSessions { get; init; } = true;
|
||||
public int GapMinutes { get; init; } = 45;
|
||||
public int MinimumFrames { get; init; } = 8;
|
||||
@@ -78,6 +83,7 @@ public sealed record ImportChoices
|
||||
IncludeSubfolders = IncludeSubfolders,
|
||||
VerifyCopies = VerifyCopies,
|
||||
Duplicates = Duplicates,
|
||||
Grouping = Grouping,
|
||||
Titles = titles ?? new Dictionary<string, string>(),
|
||||
SplitBefore = splits ?? new HashSet<string>(),
|
||||
MergeAt = merges ?? new HashSet<string>(),
|
||||
@@ -88,6 +94,7 @@ public sealed record ImportChoices
|
||||
previous.Destination != Destination
|
||||
|| (Destination == ImportDestinationKind.Folder && !string.Equals(previous.FolderPath, FolderPath, StringComparison.OrdinalIgnoreCase))
|
||||
|| previous.IncludeSubfolders != IncludeSubfolders
|
||||
|| previous.Grouping != Grouping
|
||||
|| previous.SplitSessions != SplitSessions
|
||||
|| (SplitSessions && previous.GapMinutes != GapMinutes)
|
||||
|| previous.MinimumFrames != MinimumFrames
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Chronos.App.Infrastructure;
|
||||
using Chronos.App.Settings;
|
||||
using Chronos.Core.Archiving;
|
||||
using Chronos.Core.Import;
|
||||
using Chronos.Core.Localization;
|
||||
@@ -40,7 +41,8 @@ public sealed record PlanTotals(int Sessions, int Photos, int CopyCount, long Co
|
||||
}
|
||||
|
||||
/// <summary>One row of the session table: what the planner grouped and where it goes.</summary>
|
||||
/// <param name="DefaultTitle">Title the sequence gets when the user types none (its folder name).</param>
|
||||
/// <param name="Title">The title the user typed; null when none.</param>
|
||||
/// <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>
|
||||
@@ -116,10 +118,19 @@ public static class ImportPlans
|
||||
],
|
||||
};
|
||||
|
||||
/// <summary>The plan with the typed session titles (when no template uses <c>{title}</c>, so no name changes).</summary>
|
||||
/// <summary>
|
||||
/// The plan with the typed session titles (when no template uses <c>{title}</c>, so no name changes); a session
|
||||
/// without one keeps its default title (a whole folder's name).
|
||||
/// </summary>
|
||||
public static ImportPlan WithTitles(ImportPlan plan, IReadOnlyDictionary<string, string> titles) => plan with
|
||||
{
|
||||
Sessions = [.. plan.Sessions.Select(s => s with { Title = titles.TryGetValue(s.SessionKey, out var t) && !string.IsNullOrWhiteSpace(t) ? t.Trim() : null })],
|
||||
Sessions =
|
||||
[
|
||||
.. plan.Sessions.Select(s => s with
|
||||
{
|
||||
Title = titles.TryGetValue(s.SessionKey, out var t) && !string.IsNullOrWhiteSpace(t) ? t.Trim() : s.DefaultTitle,
|
||||
}),
|
||||
],
|
||||
};
|
||||
|
||||
/// <param name="existingFolders">Folders of sequences already in the archive (a session there continues it).</param>
|
||||
@@ -135,20 +146,35 @@ public static class ImportPlans
|
||||
ImportDestinationKind.Folder => s.Folder,
|
||||
_ => Loc.L(isNew ? "Import.Session.New" : "Import.Session.Adds", s.Folder),
|
||||
};
|
||||
return new PlanSessionRow(s.Number, s.SessionKey, s.Title, leaf, TimeText(s), FramesText(s), Formatting.Bytes(s.Items.Sum(i => i.Size)),
|
||||
PathTemplate.CameraName(s.CameraMake, s.CameraModel), target, isNew, s.Items.Count > 0 ? s.Items[0].SourcePath : string.Empty,
|
||||
// The field shows a typed title only; the default (a whole folder's name, else the folder's) is its placeholder.
|
||||
var typed = s.Title is { } title && title != s.DefaultTitle ? title : null;
|
||||
return new PlanSessionRow(s.Number, s.SessionKey, typed, s.DefaultTitle ?? leaf, TimeText(s), FramesText(s),
|
||||
Formatting.Bytes(s.Items.Sum(i => i.Size)), CameraText(plan, s), target, isNew, s.Items.Count > 0 ? s.Items[0].SourcePath : string.Empty,
|
||||
MergeTarget(plan, s)?.Number);
|
||||
}),
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// "Canon EOS R5"; for a whole folder, one row per format, the format too and how many bodies took the photos:
|
||||
/// "Canon EOS R5 · CR3", "2 cameras · JPEG".
|
||||
/// </summary>
|
||||
private static string CameraText(ImportPlan plan, PlannedSession s)
|
||||
{
|
||||
var camera = PathTemplate.CameraName(s.CameraMake, s.CameraModel);
|
||||
if (plan.Grouping != ImportGrouping.WholeFolder) return camera;
|
||||
var bodies = s.Cameras > 1 ? Loc.Plural("Import.Session.Cameras", s.Cameras) : camera;
|
||||
return string.Join(Loc.Separator, new[] { bodies, FormatNames.Of(s.Format) }.Where(t => t.Length > 0));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The session <paramref name="session"/> joins when the user merges it (BRIEF §13): the one before it of the same
|
||||
/// camera body and format, whose last photo precedes its first; sessions of other cameras or formats never merge.
|
||||
/// A whole folder's parts (split by the user) join the part before them of the same format, whatever the camera.
|
||||
/// </summary>
|
||||
public static PlannedSession? MergeTarget(ImportPlan plan, PlannedSession session) =>
|
||||
plan.Sessions.TakeWhile(s => !ReferenceEquals(s, session))
|
||||
.LastOrDefault(s => s.CameraMake == session.CameraMake && s.CameraModel == session.CameraModel && s.CameraSerial == session.CameraSerial
|
||||
&& s.Format == session.Format);
|
||||
.LastOrDefault(s => s.Format == session.Format && (plan.Grouping == ImportGrouping.WholeFolder
|
||||
|| (s.CameraMake == session.CameraMake && s.CameraModel == session.CameraModel && s.CameraSerial == session.CameraSerial)));
|
||||
|
||||
/// <summary>"Show plan": every file and where it goes, with the conflicts the plan resolved or reports.</summary>
|
||||
public static PlanDetails Details(ImportPlan plan, ImportDestinationKind destination, bool verify)
|
||||
|
||||
Reference in new issue
Block a user