Fix stash deletion failing when trash is disabled#122
Open
grub-basket wants to merge 1 commit into
Open
Conversation
backupStash() called Trash.newFile(), which raises Trash.BackupSkipped when the trash is disabled (maxTrashFiles == 0). backupStash did not catch it, so DropStash and 'apply and delete' aborted with an error and the stash was never removed. The dead 'if not trashFile' guard assumed newFile() returns None, which it never does. Catch Trash.BackupSkipped and skip the backup, matching how DiscardFiles handles the same exception.
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.
Problem
backupStash()callsTrash.instance().newFile(), which callsensureTrashEnabled()and raisesTrash.BackupSkippedwhen the trash is disabled (maxTrashFiles == 0, a supported preference value).backupStashdoesn't catch it, so the exception propagates out ofDropStashand out ofApplyStashwhen "delete the stash if it applies cleanly" is ticked.The existing
if not trashFile: returnguard is dead code —newFile()never returnsNone; it either returns aPathor raises.Repro
Fix
Catch
Trash.BackupSkippedinbackupStashand skip the backup, mirroring howDiscardFilesalready handles the same exception. Added a module logger for the warning.Prepared with Claude Fable 5 (Low effort mode).