fix(archive): Reorganize never plans a move onto a folder of the exact name, keeps long names' extensions, says why a template is refused
Second fix round of owner review 2, phase 4a (planner findings).
- A sequence keeps a folder that differs from its own in case only while no
other folder holds that exact name (RenamePlanner.ExistsExactly, every level
compared exactly). On a case-sensitive file system a stray "Trip (2)" beside
the sequence at "trip (2)" no longer gives a case-only step that MoveFolder
refuses at every archive open: the plan gives "Trip", and a plan whose
target appeared since is refused under the step's leases before anything
moves (or dropped when it resumes). A change of case in an outer level no
longer looks like two folders on Windows.
- A file name longer than 200 characters is shortened before the ".{ext}" the
template ends with, never through it, so a long title never strips the
photo's extension.
- The archive engine's own settings check applies the template rules the
server and the desktop apply (a folder scans skip, a lost extension, names
that repeat), so archive.json can no longer take such a template.
- The server's invalid_template answer names the rule after the field
("fileTemplate:extension") with the desktop's sentence as its message; both
admin panels show it on the field.
- FrameNaming keeps only the naming overloads production uses.
- Comments about Unreadable say the whole sequence stays as it is.
- Tests pin filing against Reorganize: an upload without a capture time, a
card's second session with {session}, a duplicate skipped mid-session, and a
whole folder of two cameras named with the first one's camera.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 50fe59aec1e180daa1733bcb951892a79dceba6c)
This commit is contained in:
1 parent
9e1f109b58
commit
765f0ad36b
20 files changed
+446
-141
No files matched your search
@@ -515,13 +515,19 @@ public sealed record ArchiveSettings(string Name, LayoutTemplates Templates, Pro
|
||||
&& Proxies.LongEdge == archive.ProxyLongEdge;
|
||||
}
|
||||
|
||||
/// <summary>The first invalid field by its API name (<c>name</c>, <c>folderTemplate</c>, <c>fileTemplate</c>,
|
||||
/// <c>proxyLongEdge</c>, <c>thumbnailLongEdge</c>); null when every field is valid.</summary>
|
||||
/// <summary>
|
||||
/// The first invalid field by its API name (<c>name</c>, <c>folderTemplate</c>, <c>fileTemplate</c>,
|
||||
/// <c>proxyLongEdge</c>, <c>thumbnailLongEdge</c>); null when every field is valid. The templates are held to the rules
|
||||
/// they meet wherever they are typed (<see cref="RenameTemplates.Problem"/>, <see cref="TemplateRules"/>): besides
|
||||
/// parsing, a folder template may not write a level scans never enter, and a file template must keep the photo's
|
||||
/// extension, tell a session's photos apart and hold no slash.
|
||||
/// </summary>
|
||||
public string? Problem()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Name) || Name.Trim().Length > MaxNameLength) return "name";
|
||||
if (string.IsNullOrWhiteSpace(Templates.Folder) || !PathTemplate.Parse(Templates.Folder).IsValid) return "folderTemplate";
|
||||
if (string.IsNullOrWhiteSpace(Templates.File) || !PathTemplate.Parse(Templates.File).IsValid) return "fileTemplate";
|
||||
if (string.IsNullOrWhiteSpace(Templates.Folder)) return "folderTemplate";
|
||||
if (string.IsNullOrWhiteSpace(Templates.File)) return "fileTemplate";
|
||||
if (new RenameTemplates(Templates.Folder, Templates.File).Problem() is { } template) return template;
|
||||
if (!ProxyPolicy.IsValidLongEdge(Proxies.LongEdge) || Proxies.Quality is < 1 or > 100) return "proxyLongEdge";
|
||||
if (!ThumbnailPolicy.IsValidLongEdge(Thumbnails.LongEdge) || Thumbnails.Quality is < 1 or > 100) return "thumbnailLongEdge";
|
||||
return null;
|
||||
|
||||
@@ -124,7 +124,7 @@ public sealed class MassRenamer
|
||||
}
|
||||
}
|
||||
return RenamePlanner.Plan(archive.Id, subjects, templates.Folder, templates.Title, locations.Select(l => l.Folder),
|
||||
folder => Directory.Exists(paths.Sequence(folder).Folder), nested, templates.File);
|
||||
folder => Directory.Exists(paths.Sequence(folder).Folder), nested, templates.File, folder => RenamePlanner.ExistsExactly(paths, folder));
|
||||
}
|
||||
|
||||
private static RenameSubject Subject(Sequence s) => new(s.Id, s.Folder, s.Title, s.FirstCapture, s.CameraMake, s.CameraModel, s.Lens);
|
||||
@@ -631,11 +631,14 @@ public sealed class MassRenamer
|
||||
/// <summary>
|
||||
/// Whether something took the new folder of a step whose folder has not moved yet: a folder there on disk, or a sequence
|
||||
/// the index has there, around it or inside it (a restore from the trash, an upload or an import since the plan). A
|
||||
/// change of case only is the step's own folder.
|
||||
/// change of case only is the step's own folder, unless another folder holds the new name exactly beside it (a
|
||||
/// case-sensitive file system), which <see cref="RenamePlanner.MoveFolder"/> could never move onto.
|
||||
/// </summary>
|
||||
private static bool TargetTaken(ArchivePaths paths, RenameStep step, IReadOnlyList<SequenceLocation> locations)
|
||||
{
|
||||
if (!step.MovesFolder || step.FromFolder.Equals(step.ToFolder, StringComparison.OrdinalIgnoreCase) || Moved(paths, step)) return false;
|
||||
if (!step.MovesFolder || Moved(paths, step)) return false;
|
||||
if (step.FromFolder.Equals(step.ToFolder, StringComparison.OrdinalIgnoreCase))
|
||||
return RenamePlanner.ExistsExactly(paths, step.ToFolder) && RenamePlanner.ExistsExactly(paths, step.FromFolder);
|
||||
return Directory.Exists(paths.FromRelative(step.ToFolder)) || locations.Any(l => l.Id != step.SequenceId
|
||||
&& (l.Folder.Equals(step.ToFolder, StringComparison.OrdinalIgnoreCase) || RenamePlanner.IsInside(l.Folder, step.ToFolder)
|
||||
|| RenamePlanner.IsInside(step.ToFolder, l.Folder)));
|
||||
|
||||
Reference in new issue
Block a user