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:
Alby96andClaude Opus 5.5 committed 2026-10-26 22:00:55 +01:00
1 parent 5209579631
commit 445dfd41a3
14 files changed
+419 -26

No files matched your search

@@ -94,6 +94,16 @@ public sealed class ImportChoicesTests
Assert.SequenceEqual([fresh.Id], joined.Without(own.Id).Cards);
}
[Test]
public void TheGroupingTravelsToThePlannerButNeverIntoACardProfile()
{
var whole = new ImportChoices { Grouping = ImportGrouping.WholeFolder };
Assert.Equal(ImportGrouping.WholeFolder, whole.ToOptions().Grouping);
Assert.Equal(ImportGrouping.Sessions, new ImportChoices().ToOptions().Grouping, "a source starts with its sessions");
Assert.True(whole.NeedsNewPlan(new ImportChoices()), "the grouping changes which photos form which sequence");
Assert.Equal(ImportGrouping.Sessions, ImportChoices.FromProfile(whole.ToProfile()).Grouping, "a card always imports by sessions");
}
[Test]
public void SplitsAndMergesTravelToThePlanner()
{
@@ -1,5 +1,6 @@
using System.Globalization;
using Chronos.App.Import;
using Chronos.Core.Imaging;
using Chronos.Core.Import;
using Chronos.Core.Localization;
using Chronos.Testing;
@@ -175,6 +176,51 @@ public sealed class ImportPlansTests
Assert.Equal(1, split[2].MergesInto, "the earlier session of the same body, skipping the other camera");
}
[Test]
public void AWholeFolderRowShowsItsFormatAndCamerasWithTheFolderNameAsDefaultTitle()
{
var jpeg = Session(1, "2026/2026-09-28 Canon EOS R5", Item(1, Start), Item(2, Start.AddHours(5))) with
{
SessionKey = "folder-jpeg",
Format = ImageFileFormat.Jpeg,
Cameras = 2,
Title = "Etna",
DefaultTitle = "Etna",
};
var raw = Session(2, "2026/2026-09-28 Canon EOS R5 (2)", Item(3, Start), Item(4, Start.AddHours(5))) with
{
SessionKey = "folder-raw",
Title = "Etna",
DefaultTitle = "Etna",
};
var plan = Plan(null, null, jpeg, raw) with { Grouping = ImportGrouping.WholeFolder };
var rows = ImportPlans.Sessions(plan, ImportDestinationKind.Archive, new HashSet<string>());
Assert.Equal("2 cameras · JPEG", rows[0].CameraText);
Assert.Equal("Canon EOS R5 · CR2", rows[1].CameraText);
Assert.Null(rows[0].Title, "the folder's name is the placeholder, not typed text");
Assert.Equal("Etna", rows[0].DefaultTitle);
Assert.Null(rows[1].MergesInto, "another format never merges");
var bySessions = ImportPlans.Sessions(plan with { Grouping = ImportGrouping.Sessions }, ImportDestinationKind.Archive, new HashSet<string>());
Assert.Equal("Canon EOS R5", bySessions[1].CameraText);
var titled = ImportPlans.WithTitles(plan, new Dictionary<string, string> { ["folder-jpeg"] = "Etna at night" });
Assert.Equal("Etna at night", titled.Sessions[0].Title);
Assert.Equal("Etna", titled.Sessions[1].Title, "a sequence without a typed title keeps the folder's name");
Assert.Equal("Etna at night", ImportPlans.Sessions(titled, ImportDestinationKind.Archive, new HashSet<string>())[0].Title);
}
[Test]
public void AWholeFolderPartMergesBackIntoThePartBeforeItOfTheSameFormatWhateverItsCamera()
{
var first = Session(1, "2026/Etna", Item(1, Start));
var second = Session(2, "2026/Etna (2)", Item(2, Start.AddHours(1))) with { CameraMake = "Nikon", CameraModel = "NIKON Z 8" };
var plan = Plan(null, null, first, second) with { Grouping = ImportGrouping.WholeFolder };
Assert.Equal(1, ImportPlans.Sessions(plan, ImportDestinationKind.Archive, new HashSet<string>())[1].MergesInto);
Assert.Null(ImportPlans.Sessions(plan with { Grouping = ImportGrouping.Sessions }, ImportDestinationKind.Archive, new HashSet<string>())[1].MergesInto,
"sessions of another camera never merge");
}
[Test]
public void ShowPlanOffersASplitOnEveryPhotoButTheFirstOfItsSession()
{