Skip to content

Fix stash deletion failing when trash is disabled#122

Open
grub-basket wants to merge 1 commit into
jorio:masterfrom
grub-basket:fix/stash-delete-trash-disabled
Open

Fix stash deletion failing when trash is disabled#122
grub-basket wants to merge 1 commit into
jorio:masterfrom
grub-basket:fix/stash-delete-trash-disabled

Conversation

@grub-basket

Copy link
Copy Markdown

Problem

backupStash() calls Trash.instance().newFile(), which calls ensureTrashEnabled() and raises Trash.BackupSkipped when the trash is disabled (maxTrashFiles == 0, a supported preference value). backupStash doesn't catch it, so the exception propagates out of DropStash and out of ApplyStash when "delete the stash if it applies cleanly" is ticked.

The existing if not trashFile: return guard is dead code — newFile() never returns None; it either returns a Path or raises.

Repro

  1. Preferences → set the trash to keep 0 discarded patches.
  2. Drop a stash (or apply-and-delete a stash).
  3. The task aborts with an error dialog and the stash is never removed.

Fix

Catch Trash.BackupSkipped in backupStash and skip the backup, mirroring how DiscardFiles already handles the same exception. Added a module logger for the warning.


Prepared with Claude Fable 5 (Low effort mode).

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.
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