fix(mods): removing a mod's old entry no longer deletes its only copy #3078
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3078
Loading…
Reference in a new issue
No description provided.
Delete branch "llun/Longshot:fix/mod-remove-keeps-unlabelled-folder"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
A player whose mods an older launcher added sees each one twice on the Mods page, and Remove on the row marked missing deletes the mod's only copy.
The launcher's entry in
profile.jsonnames a folder whosemod.jsonnothing reads any more (since #2822). The game lists that folder aslocal/<folder>, and the entry as missing.mod removeof the entry deleted the folder all the same.Now
mod removekeeps a folder when the game lists it under another id, or lists another mod inside it. It finds them with the game's own walk (code_mods::walk). The entry goes, so the double goes too. An entry of the folder's own id, a mod with amod.toml, a folder with no mod in it and a folder no entry names are deleted as before. A path outsidemods/is refused before it is looked at, as before this change.See it on
main: the first commit's test fails, with the folder indeleted. Readanother_modingame/crates/modtool/src/service.rsfirst.MagicBeanDev/LongshotLauncher#410 stops the doubling itself. This protects players whose launcher does not have it yet.
Testing
Tested: Windows 11, RTX 5080, driver 621.47. On the first version of this change (
d7ad5f9d4; the same for this profile's folder), a throwaway profile with one folder (a RomFS file, amod.json, nomod.toml) and an entry of another id:mod removeof the missing row answered"deleted": [], the folder stayed, and one row was left.kokiri-start: it reached play, 600 frames, the Insert menu opened, the mod loaded (mods: local/Grass: 1 RomFS files), no error lines. On the profile before the remove it also loaded once. That game was built frommain@b4d56f526plus one menu fix (b1b433ee9), not from this branch, which changes only the builder'smod remove; a build of this branch did not fit on the disk.Checks, on
67a669a85: the three new tests pass, the two newer ones failed on the versions before they were fixed, and the first fails onmain. Undoing key lines of the guard, one at a time, makes one fail. modtool'sservice,cmd::state,import,profile,emulatorsandhandletests, itscargo fmt --checkand its Clippy with-D warningspass. The whole suite ran ond7ad5f9d4:mise run testwas stopped near its end for disk space, and the five checks left were then run on their own. All pass but three:test_i18n_completefails, as it does onmain.test_lifter: its rustfmt and Clippy pass, and so does all ofcargo test --release --workspace --no-fail-fast(modtool's 230 among them) butevery_site_has_one_owner_and_the_sites_are_the_ones_before_the_split(sites,tests/repository.rs), which fails the same way onmain@b4d56f526.test_stack_commitfailed once with the PC low on space, and passes alone here and onmain.Still to test:
Measurements
Verdict: fixed: the folder is kept, the test failing on
mainpasses here.Setup: Windows 11, no game;
cargo test -p modtool --lib removing_an_entryb4d56f52667a669a85removing_an_entry_keeps_a_folder_that_is_another_mod_to_the_gamedeletednames the folderdeletedis emptyRisks
Removing an entry like that leaves its folder in
mods/; the folder's own row still removes it. The launcher's question still says the folder is deleted. A revert is enough. Saves, settings and caches: nothing.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.Tested in game: Windows 11, RTX 5080, driver 621.47, headless from kokiri-start. This branch's builder removed the missing row of a doubled throwaway profile ("deleted": []), then the game ran on that profile: in play, 600 frames, the Insert menu opened, mods: local/Grass: 1 RomFS files, no error lines. The game was built from main @
b4d56f526plus one menu fix (b1b433ee9), not from this branch: it changes only the builder's mod remove, and a build of it did not fit on the disk.The checks left out earlier for disk space have run now.
test_lifter's only failure,every_site_has_one_owner_and_the_sites_are_the_ones_before_the_split, fails the same way onmain@b4d56f526.test_reshade_fxpasses.WIP: fix(mods): removing a mod's old entry no longer deletes its only copyto fix(mods): removing a mod's old entry no longer deletes its only copy@review
Recommendation: Request changes. The guard can still delete a folder containing a mod the game lists under another ID, and it reads unvalidated profile paths before the existing deletion guard can refuse them. The launcher removal flow also still needs its stated manual test.
The change preserves a directly contained emulator-layout mod when removing an older mismatched profile entry, and its new test covers that case. Its separate layout check does not cover all folders the game discovers.
Blocking (2): must change before merging.
game/crates/modtool/src/service.rs:1223: The import detector does not find every mod that the game's discovery walk finds, so this guard can still delete another listed mod's only copy. (more on the line) Do: Use the game's discovery rules to detect any separately listed mod within the folder before deleting it, and add a regression test for a nested mod.game/crates/modtool/src/service.rs:1222: The new filesystem probe uses the profile's manual path before validating that it is a direct child of mods. (more on the line) Do: Validate the manual path as a single local mods child before any filesystem access, and test an absolute network path in a profile entry.Testing before merging (1) (the change behaves the same on every system: one run of the change itself is enough; it doesn't hold the recommendation)
@fixcan do L1 and L2.Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes for the tested case: the author reports the new test fails on main and passes on this head, and a Windows builder run kept the folder and removed the entry. The launcher's Mods page flow has not yet been tested.
Other systems: The game and builder share the mod discovery walk, which also finds nested mods and patch sets; the new removal guard uses a narrower import detector. The path probe also runs on Windows and Linux for profile-supplied manual paths.
Switches: None.
Reviewed:
d7ad5f9d4dagainstb4d56f5264: Read the repository instructions, CONTRIBUTING.md, the pull request template, the diff and commit messages, and the changed removal and test sections with their discovery, path-validation and profile-locking code. Skimmed the rest of the changed files and standards; the full changed files were not all read in full. docs/review-checklist.md and the adjacent Tooling checkout were absent.; nothing run (a code review).Checked and fine:
Testing: No commands from the pull request were run. The author reports a passing targeted test and Windows builder and game checks; CI is still running.
Overlaps and merge order: LongshotLauncher#410 addresses the doubling itself; this change is intended to protect users before that launcher fix reaches them.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, as llun took it out of WIP. Nothing was run; a maintainer decides.
@ -1216,0 +1219,4 @@fn another_mod(dir: &Path, id: &str, rel: &str) -> bool {let name = rel.strip_prefix("mods/").unwrap_or(rel).trim_end_matches('/');let at = dir.join("mods").join(name);std::fs::symlink_metadata(&at).is_ok_and(|m| m.is_dir())L2 (blocking): The new filesystem probe uses the profile's manual path before validating that it is a direct child of mods.
When: A profile entry containing an absolute Windows network path causes join to replace the mods path and symlink_metadata to access that network location when the entry is removed. Previously delete_own refused that path before accessing it.
Do: Validate the manual path as a single local mods child before any filesystem access, and test an absolute network path in a profile entry.
@ -1216,0 +1220,4 @@let name = rel.strip_prefix("mods/").unwrap_or(rel).trim_end_matches('/');let at = dir.join("mods").join(name);std::fs::symlink_metadata(&at).is_ok_and(|m| m.is_dir())&& crate::import::is_emulator_mod(&at)L1 (blocking): The import detector does not find every mod that the game's discovery walk finds, so this guard can still delete another listed mod's only copy.
When: If an old entry points to mods/Pack and its mod is at mods/Pack/Grass/romfs, the game lists local/Pack/Grass. is_emulator_mod checks only Pack's immediate children, returns false, and removing the old entry deletes Pack and Grass.
Do: Use the game's discovery rules to detect any separately listed mod within the folder before deleting it, and add a regression test for a nested mod.
d7ad5f9d4d92df94f7e9Both are fixed in
92df94f7e, each with a test that failed on the first version. The branch still reads test, then fix.code_mods::walk). It is kept when that finds a mod the game lists under another id: one deeper in the folder, a patch set, a package, or amod.tomlmod below it. An entry of the folder's own mod, and a folder with no mod in it, are deleted as before. Test:removing_an_entry_keeps_a_folder_that_holds_another_mod.check_manual_path) before any file access, anddelete_ownrefuses the rest as it did. Test:removing_an_entry_never_looks_at_a_path_outside_mods, with absolute,mods/+ absolute,..and network paths.Not run again on this head: the game and the whole suite.
cargo test -p modtoolfor the parts this touches,cargo fmt --checkand Clippy pass on Windows.@review
Recommendation: Request changes. The guard still deletes a folder when its root manifest identifies a different mod from the removed entry. The launcher flow also remains untested.
The change protects legacy launcher entries and nested mods from deletion by using the game's discovery walk. It adds a small filesystem scan on removal, but misses a different mod identified by a manifest at the folder root.
Blocking (1): must change before merging.
game/crates/modtool/src/service.rs:1223: A root manifest mod is assumed to belong to the entry being removed, even when its manifest names a different mod. When: If an entry for local/old points to mods/Whole and Whole/mod.toml identifies me/whole, the game lists me/whole, but the root spot has s.rel == name. The guard returns false and delete_own deletes its only folder. Do: Resolve the root manifest's game-visible id and keep the folder when it differs from the removed entry; cover that case with a regression test.Testing before merging (1) (the change behaves the same on every system: one run of the change itself is enough; it doesn't hold the recommendation)
@fixcan do L1.Since the last review (on
d7ad5f9d4d)Resolved: L2 (The new filesystem probe uses the profile's manual path before validating that it is a dir…)
Still open: L1 (A root manifest mod is assumed to belong to the entry being removed, even when its manifes…); L3 (The launcher flow that players use for the reported bug remains untested.)
Checks: Still running:
PR description / Title and description (pull_request_target).More: does it help, other systems, switches, what was read
Does it help: Yes: the reported Windows test kept the legacy folder and removed the duplicate entry; the new regression test is reported to fail on main and pass on this head. The launcher interaction has not yet been tested.
Other systems: The builder's remove operation runs on Windows and Linux; the guard uses the shared game discovery walk and checks the manual path before probing it. The game itself does not run the changed removal code.
Switches: None.
Reviewed:
92df94f7e9againstb4d56f5264: Read the diff, the changed removal logic and tests, the manual-path validator, the shared discovery walk and the game's discovery caller. Read AGENTS.md and CONTRIBUTING.md, though the combined output was truncated; the full changed files and pull request template were not read. The sibling Tooling rules and review checklist were unavailable.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run the project were executed. The author reports focused tests, formatting and Clippy passing on Windows; the launcher flow remains outstanding.
Overlaps and merge order: LongshotLauncher#410 addresses the duplicate rows themselves; this change also protects users of older launchers.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
92df94f7e9fecd2b9c1cL1's last case is fixed in
fecd2b9c1: for each mod found, the guard works out the id the game lists it under. That is the id in itsmod.tomlwhen that reads and the folder may be it, elselocal/<its folder>. The folder is kept when that id is not the removed entry's.removing_an_entry_keeps_a_folder_that_holds_another_modnow also covers a folder whosemod.tomlnames another mod (kept), one whosemod.tomlcannot be read under another id (kept) and under its own (deleted). It failed on92df94f7e, on the first of these. Taking out either new part of the guard makes it fail.On Windows, modtool's
service,cmd::state,import,profile,emulatorsandhandletests,cargo fmt --checkand Clippy with-D warningspass. L3 stays under Still to test.@review
Recommendation: Request changes. The guard still deletes a root manifest mod belonging to a different ID when its manifest is exactly the game’s maximum accepted size. The launcher’s Remove flow also remains untested.
Removing an outdated profile entry normally keeps a folder that the game lists as another mod, preventing loss of the mod’s only copy. The new manifest check improves coverage but has a one-byte limit mismatch with the game.
Blocking (1): must change before merging.
game/crates/modtool/src/service.rs:1223: The manifest read limit is one byte smaller than the game’s limit. When: For a valid 1,048,576-byte root mod.toml naming a different mod, removing an entry named local/ makes the guard fall back to that local ID and delete the folder, although the game lists the manifest’s ID. Do: Read up to the same manifest limit as the game and cover the boundary with a regression test.Testing before merging (1) (the change behaves the same on every system: one run of the change itself is enough; it doesn't hold the recommendation)
@fixcan do L1.Since the last review (on
92df94f7e9)Still open: L1 (The manifest read limit is one byte smaller than the game’s limit.); L3 (The launcher flow that players use for the reported bug remains untested.)
Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes for the reported case: the author reports that the regression test fails on main and passes on this head, and that the builder kept the folder in a Windows run. The maximum-size manifest case remains broken.
Other systems: The guard uses the shared mod walk and affects builder removal on Windows and Linux; it does not change the game loader. The author tested the builder on Windows and the resulting profile in a game built from main.
Switches: None.
Reviewed:
fecd2b9c1cagainstb4d56f5264: Read the pull request diff, commits, repository rules and template, removal and manifest-discovery paths, and the relevant tests. The changed source files were not read in full; other tests and documentation were skimmed. Tooling’s AGENTS.md was unavailable locally.; nothing run (a code review).Checked and fine:
Testing: No commands from the project were run. The author reports targeted tests, formatting and Clippy passing on Windows; CI is still running. The launcher Remove flow remains to be tested by hand.
Overlaps and merge order: The description identifies LongshotLauncher#410 as stopping the duplicate display; this change protects players without that launcher fix.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
@review
Recommendation: Request changes. The guard can still delete the only copy of a mod when its valid manifest is exactly 1,048,576 bytes. The launcher Remove flow also remains untested.
Removing an obsolete profile entry usually keeps a folder that the game recognizes as another mod, avoiding loss of its only copy. The added walk and manifest read leave an outstanding limit mismatch.
Blocking (1): must change before merging.
game/crates/modtool/src/service.rs:1223: The manifest read limit is one byte smaller than the game’s limit. When: For a valid 1,048,576-byte root mod.toml naming a different mod, removing an entry named local/ makes the guard fall back to that local ID and delete the folder, although the game lists the manifest’s ID. Do: Read up to the same manifest limit as the game and cover the boundary with a regression test.Testing before merging (1) (the change behaves the same on every system: one run of the change itself is enough; it doesn't hold the recommendation)
@fixcan do L1.Since the last review (on
fecd2b9c1c)Still open: L1 (The manifest read limit is one byte smaller than the game’s limit.); L3 (The launcher flow that players use for the reported bug remains untested.)
Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes for the reported case: the author reports that the new test fails on main because the folder is deleted and passes on this head with an empty deleted list. The launcher flow has not yet been exercised.
Other systems: The builder removal path affects Windows and Linux profiles; the recorded builder and game run was on Windows. The game uses a different manifest read limit, leaving the boundary case open.
Switches: None.
Reviewed:
fecd2b9c1cagainstb4d56f5264: Read the ledger, pull request description and comments, repository guidance and template, the diff and commits, and the relevant manifest limit and removal code. The changed code files and their callers were not read in full; recorded runs were reviewed from the description and comments.; nothing run (a code review).Checked and fine:
Testing: No commands that run project code were executed. The author reports passing targeted Windows tests, formatting and Clippy; CI is still running.
Overlaps and merge order: LongshotLauncher#410 addresses the duplicate listing itself; this change protects profiles used with launchers that lack that fix. No merge order is stated.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
fecd2b9c1c67a669a85bL1's limit is fixed in
67a669a85: the guard reads themod.tomlwith the game's own reader (api::disk::OsDisk) and limit (api::loader::MANIFEST_MAX), so the two cannot differ.removing_an_entry_keeps_a_folder_that_holds_another_modnow has amod.tomlof exactly that many bytes. It failed onfecd2b9c1, and it fails with the limit one byte lower. On Windows (gnullvm), modtool'sservicetests,cargo fmt --checkand Clippy with-D warningspass. L3 stays under Still to test.@review
Recommendation: Approve. The code is ready: only testing is left (a run of the change itself). The manifest limit now matches the game's reader, and the reported builder test shows the original deletion bug fixed. The launcher’s Remove flow still needs a manual run, and CI is still running. Recommend approval; not approved on the forge.
Removing an obsolete mod entry keeps a folder that the game recognizes as another mod, preventing loss of its only copy. The guard adds a filesystem walk and manifest read when removing a manual entry.
Testing before merging (1) (the change behaves the same on every system: one run of the change itself is enough; it doesn't hold the recommendation)
Since the last review (on
fecd2b9c1c)Resolved: L1 (The manifest read limit is one byte smaller than the game’s limit.)
Still open: L3 (The launcher flow that players use for the reported bug remains untested.)
Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes: the author reports that the regression test fails on main because the folder appears in deleted, and passes on this head with deleted empty. The builder flow was also exercised on Windows; the launcher UI flow remains untested.
Other systems: The guard uses the game’s manifest reader and limit on the builder path. The author reports Windows tests; the launcher integration remains to be exercised. GPU-specific behavior is unaffected.
Switches: None.
Reviewed:
67a669a85bagainstb4d56f5264: Read the repository rules, PR template, full diff, commit list, disk reader and relevant loader and guard code. Large changed files, documentation and walk implementation were only skimmed because the combined output was truncated; docs/review-checklist.md was absent.; nothing run (a code review).Checked and fine:
Testing: No commands from the project or tests were run. The author reports passing focused Windows tests, formatting and Clippy; CI remains in progress.
Overlaps and merge order: LongshotLauncher#410 addresses the duplicate listing itself; this change protects profiles used with older launchers and does not require it to merge first.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.