Verify exact mod membership names after case-only renames (by Codex)
This commit is contained in:
1 parent
6bcd95d668
commit
a0bb8b47dc
2 files changed
+14
No files matched your search
@@ -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))
|
if (expected.id != expected.name || expected.path != root / "mods" / editor::path(expected.id))
|
||||||
throw editor::Error("Die Mod gehört nicht zu dieser Bibliothek.");
|
throw editor::Error("Die Mod gehört nicht zu dieser Bibliothek.");
|
||||||
member_name(expected.id);
|
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))
|
if (fs::is_symlink(fs::symlink_status(expected.path)) || !fs::is_directory(expected.path))
|
||||||
throw editor::Error("Unsicheres oder fehlendes Mod-Verzeichnis.");
|
throw editor::Error("Unsicheres oder fehlendes Mod-Verzeichnis.");
|
||||||
const auto actual = entry(root, expected.id);
|
const auto actual = entry(root, expected.id);
|
||||||
|
|||||||
@@ -261,7 +261,12 @@ void lifecycle() {
|
|||||||
selected = library.snapshot();
|
selected = library.snapshot();
|
||||||
const auto renamed = library.rename(first, "ÖFFNUNG", selected.selection_token);
|
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");
|
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");
|
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 foreign = UiModLibrary(fixture.root / "other").commit(library.inspect(source), "Foreign");
|
||||||
const auto stable = tree(portable);
|
const auto stable = tree(portable);
|
||||||
rejected([&] { library.remove(foreign, library.snapshot().selection_token); }, "Foreign library membership accepted");
|
rejected([&] { library.remove(foreign, library.snapshot().selection_token); }, "Foreign library membership accepted");
|
||||||
|
|||||||
Reference in new issue
Block a user