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
Open
Conversation
…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>
glebkin
force-pushed
the
fix/apply-pending-deactivation-with-nothing-on-disk
branch
from
September 4, 2026 17:24
a155b07 to
e968b9d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.