Skip to content

fix(apply): don't bail when a mod is pending deactivation but left nothing on disk - #401

Open
glebkin wants to merge 1 commit into
faisalkindi:masterfrom
glebkin:fix/apply-pending-deactivation-with-nothing-on-disk
Open

fix(apply): don't bail when a mod is pending deactivation but left nothing on disk#401
glebkin wants to merge 1 commit into
faisalkindi:masterfrom
glebkin:fix/apply-pending-deactivation-with-nothing-on-disk

Conversation

@glebkin

@glebkin glebkin commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Fixes deactivating a mod and hitting Apply getting stuck on "Apply Failed: No mod changes to apply or revert", with the card keeping its "Apply to Deactivate" badge and every retry producing the same error.

#375 covered the case where the disabled mods had left an overlay folder behind. This is the neighbouring hole: a JSON-source mod whose patches all get skipped at apply time is still recorded as applied when that apply finishes, even though it put nothing into the game. Switching it off then left Apply with nothing to apply, nothing to revert and no leftover folder to clean, so it bailed out with an error instead of finishing -- and because it errored, the app never refreshed its record of what is applied, so the pending badge could never clear and clicking Apply again just repeated the error.

Apply now treats "the app thinks this mod is applied but the user has switched it off" as real pending work and runs the normal flow, which reconciles the record and clears the badge. Clicking Apply with nothing actually changed still reports "No mod changes to apply or revert" as before.

…thing on disk

The stale-overlay probe from faisalkindi#375 only catches disabled json_source
mods that actually managed to BUILD an overlay. A json_source mod whose
patches all get skipped at apply time (APPLY_SILENT_FAILURE, "no PAMT
entry for gamedata/inventory.pabgb in vanilla or live") still gets
snapshotted as applied=1 when that apply finishes, yet it leaves
nothing on disk at all. Turning it off afterwards gave empty
file_deltas, empty revert_files, no enabled JSON mod AND no overlay
directory, so Apply bailed with "No mod changes to apply or revert."

That path emits error_occurred instead of finished, so the GUI never
re-ran _snapshot_applied_state, the mods table kept applied=1, and the
card kept its "Apply to Deactivate" badge -- with every retry hitting
the same error. The state could not be reconciled by any user action.

The DB's own applied-vs-enabled bookkeeping is the authority on whether
the user has a pending change. When any paz mod's applied flag
disagrees with its enabled flag, run the normal apply flow (it reaches
orphan-cleanup, the PAPGT rebuild and a clean commit) so the state gets
reconciled and the badge clears. A genuine no-op -- nothing to write
and applied already equal to enabled -- still reports "No mod changes
to apply or revert" as before.

Signed-off-by: Gleb Kogtev <gleb.kogtev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant