fix(archive): a case-only target that is the sequence's own folder is kept; stored templates never fail other edits

Reorganize refused a case-only folder target whenever a folder of that exact
name was on disk. On a case-insensitive file system that folder can be the
sequence's own, when the disk spells it as the template does and the index
does not (renamed in Explorer, or an outer level a change of case left as it
was), so the plan gave a needless " (n)" folder. RenamePlanner.Kept now
refuses only when both exact names exist, the condition MassRenamer.TargetTaken
and MoveFolder already use.

ArchiveSettings.Problem held both templates to the template rules on every
UpdateSettingsAsync, so an archive.json saved before the rules made every
desktop Settings > Archive edit fail. A template the file already holds is now
only checked for being usable; a template the edit gives, and both templates
of a new archive, meet every rule. A broken rule throws TemplateRuleException
(an ArgumentException naming the field), and the desktop toast shows that
rule's sentence instead of "Something went wrong".

Also corrects comments that ignored RenameBlock.Unreadable (the whole
sequence stays as it is) and the ARCHITECTURE Naming row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit ac7a0c36df83b6d43651caf0225c530466242c97)
This commit is contained in:
Alby96 committed 2026-10-27 19:16:27 +01:00
1 parent 8127373fd5
commit 0377040a19
13 files changed
+193 -31

No files matched your search

@@ -2,9 +2,11 @@ using System.Globalization;
using System.IO;
using System.Net;
using System.Net.Http;
using Chronos.App.Infrastructure;
using Chronos.App.Shell;
using Chronos.Core.Archiving;
using Chronos.Core.Localization;
using Chronos.Data.Archiving;
using Chronos.Protocol;
using Chronos.Protocol.Client;
using Chronos.Testing;
@@ -60,4 +62,15 @@ public sealed class ErrorTextTests
Assert.Equal("Something went wrong.", ErrorText.For(new IOException(@"Access to the path 'D:\Archive' is denied.")));
Assert.Equal(@"The archive D:\Shoots is read-only.", ErrorText.For(new ArchiveOfflineException(@"D:\Shoots", ArchiveAvailability.ReadOnly)));
}
[Test]
public void ATemplateAnArchiveRefusesSaysTheRuleItBreaks()
{
// A new archive with this PC's templates, one saved before the rules existed: the toast says what to change.
var refused = new TemplateRuleException("fileTemplate", "NotUnique");
const string Sentence = "Names would repeat: add the frame number, the time or the original name.";
Assert.Equal(Sentence, ErrorText.For(refused));
Assert.Equal(Sentence, ArchiveActions.Cause(refused));
Assert.Equal("Something went wrong.", ArchiveActions.Cause(new ArgumentException("The archive setting name is invalid.", "name")));
}
}