Verify exact mod membership names after case-only renames (by Codex)

This commit is contained in:
Codex committed 2026-10-26 09:03:33 +01:00
1 parent 6bcd95d668
commit a0bb8b47dc
2 files changed
+14

No files matched your search

+9
View File
@@ -246,6 +246,15 @@ UiModEntry owned(const fs::path &root, const UiModEntry &expected, bool require_
if (expected.id != expected.name || expected.path != root / "mods" / editor::path(expected.id))
throw editor::Error("Die Mod gehört nicht zu dieser Bibliothek.");
member_name(expected.id);
// Library IDs use the spelling actually enumerated on disk, even when the
// host filesystem resolves an obsolete differently-cased path to it.
bool exact_member = false;
for (const auto &file : fs::directory_iterator(root / "mods"))
if (editor::utf8(file.path().filename()) == expected.id) {
exact_member = true;
break;
}
if (!exact_member) throw editor::Error("Diese Mod-ID wurde inzwischen geändert. Bitte erneut auswählen.");
if (fs::is_symlink(fs::symlink_status(expected.path)) || !fs::is_directory(expected.path))
throw editor::Error("Unsicheres oder fehlendes Mod-Verzeichnis.");
const auto actual = entry(root, expected.id);
+5
View File
@@ -261,7 +261,12 @@ void lifecycle() {
selected = library.snapshot();
const auto renamed = library.rename(first, "ÖFFNUNG", selected.selection_token);
require(renamed.valid() && library.snapshot().active == renamed.id && fs::exists(renamed.path / "content.obw"), "Case-only rename lost active selection");
const auto before_case_alias = tree(portable);
rejected([&] { library.activate(first, library.snapshot().selection_token); }, "Obsolete casing alias activated a renamed member");
rejected([&] { library.rename(first, "Alias rename", library.snapshot().selection_token); }, "Obsolete casing alias renamed a current member");
rejected([&] { library.remove(first, library.snapshot().selection_token); }, "Old membership token survived rename");
require(tree(portable) == before_case_alias && library.snapshot().active == renamed.id,
"Rejected old casing aliases changed files or persisted active identity");
const auto foreign = UiModLibrary(fixture.root / "other").commit(library.inspect(source), "Foreign");
const auto stable = tree(portable);
rejected([&] { library.remove(foreign, library.snapshot().selection_token); }, "Foreign library membership accepted");