fix(archive): Reorganize names as filing does and refuses templates that lose or hide photos
Reorganize with the archive's own templates planned renames and moves for
photos just filed, and some templates could strip extensions, hide sequences
from scans or stall a dry run. Owner review 2, phase 4a findings.
- Filing and Reorganize share one context: uploads and imports name every
photo with the sequence's camera and lens (its first photo's, or the
creator's hint), an upload's folder from its first frame in the new
sequence, and a missing capture time from the sequence start instead of
the current time. The planner expands folder and title templates from the
first frame in the sidecar ({name}, {ext}, {iso}...), never today's date.
- Titles expand as text (ExpandText): "Paris: night" stays as typed.
- A sequence whose sidecar cannot be read (torn, another sequence's) keeps
its folder, title and names, listed with why, and so does every folder
around it; the dry run reads every sidecar, nested ones included.
- Kept never gives one folder to two sequences of a plan whatever the case,
and a case-only move onto another folder is refused instead of taken as
done.
- Shared template rules (TemplateRules) for the server's Reorganize and
archive settings and the desktop's fields: a file template must keep the
photo's extension ("{n}{ext}" refused) and tell a session's photos apart;
a folder template may not write a level scans skip (a leading dot,
originals, proxies, exports). Levels a title gives are escaped with "_".
- {ext} comes from the file, or from the original name when the file lost
a photo's extension, so a Reorganize can put it back.
- Unique names cost linear time (UniqueNames) with the same names as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 6c734777e01476881a3f34b3188571cc3f7150ab)
This commit is contained in:
1 parent
13c2ac321c
commit
b253cac8d4
25 files changed
+777
-173
No files matched your search
@@ -61,7 +61,7 @@ public static class ReorganizePlans
|
||||
if (parsed.Errors is [var error, ..]) return Loc.L("Errors.Template." + error.Code, error.Token ?? string.Empty, error.Position + 1);
|
||||
try
|
||||
{
|
||||
foreach (var frame in NamingPreview.SampleFrames) parsed.ExpandFile(frame);
|
||||
foreach (var frame in NamingPreview.SampleFrames) parsed.ExpandText(frame);
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
|
||||
@@ -15,7 +15,10 @@ public static class NamingPreview
|
||||
/// </summary>
|
||||
public static IReadOnlyList<NamingContext> SampleFrames => BuildSample();
|
||||
|
||||
/// <summary>The first problem of <paramref name="template"/>, localized; null when it is valid.</summary>
|
||||
/// <summary>
|
||||
/// The first problem of <paramref name="template"/>, localized; null when it is valid. Beyond parsing and expanding,
|
||||
/// the rules every place a template is used shares (<see cref="TemplateRules"/>), as the server checks them.
|
||||
/// </summary>
|
||||
public static string? Validate(string? template, bool isFolder)
|
||||
{
|
||||
var text = template ?? string.Empty;
|
||||
@@ -33,12 +36,12 @@ public static class NamingPreview
|
||||
var name = isFolder ? parsed.ExpandFolder(frame) : parsed.ExpandFile(frame);
|
||||
if (name.Length == 0) return Loc.L("Errors.Template.Empty", string.Empty, 1);
|
||||
}
|
||||
if ((isFolder ? TemplateRules.FolderRule(parsed) : TemplateRules.FileRule(parsed)) is { } rule) return Loc.L("Errors.Template." + rule);
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
return Loc.L("Errors.Template.Format");
|
||||
}
|
||||
if (!isFolder && !NumbersFrames(text)) return Loc.L("Errors.Template.NotUnique");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -53,34 +56,5 @@ public static class NamingPreview
|
||||
|
||||
private static string Combine(string folder, string file) => folder.Length == 0 ? file : folder + "/" + file;
|
||||
|
||||
/// <summary>File names must tell frames apart: a frame number, the time of day or the original name.</summary>
|
||||
private static bool NumbersFrames(string template)
|
||||
{
|
||||
var parsed = PathTemplate.Parse(template);
|
||||
var names = SampleFrames.Select(parsed.ExpandFile).ToList();
|
||||
return names.Distinct(StringComparer.OrdinalIgnoreCase).Count() == names.Count;
|
||||
}
|
||||
|
||||
private static List<NamingContext> BuildSample()
|
||||
{
|
||||
var start = new DateTime(2026, 9, 28, 18, 2, 11);
|
||||
var title = Loc.L("Settings.Naming.SampleTitle");
|
||||
return Enumerable.Range(0, 3).Select(i => new NamingContext
|
||||
{
|
||||
CapturedAt = start.AddSeconds(2 * i),
|
||||
SessionStart = start,
|
||||
Session = 1,
|
||||
Number = i + 1,
|
||||
NumberInSession = i + 1,
|
||||
CameraMake = "Canon",
|
||||
CameraModel = "Canon EOS R5",
|
||||
Lens = "RF15-35mm F2.8 L IS USM",
|
||||
Iso = 100,
|
||||
ExposureTime = 1.0 / 250,
|
||||
FNumber = 8,
|
||||
OriginalName = "IMG_" + (4211 + i).ToString("0000", System.Globalization.CultureInfo.InvariantCulture),
|
||||
Extension = "CR2",
|
||||
Title = title,
|
||||
}).ToList();
|
||||
}
|
||||
private static IReadOnlyList<NamingContext> BuildSample() => TemplateRules.Sample(Loc.L("Settings.Naming.SampleTitle"));
|
||||
}
|
||||
Reference in new issue
Block a user