Skip to content

fix: keep the backup exe when an update fails; release the taskbar lock on a desktop drop - #224

Open
fix2it wants to merge 2 commits into
CodeZeno:mainfrom
fix2it:fix/updater-backup-and-locked-drag
Open

fix2it wants to merge 2 commits into
CodeZeno:mainfrom
fix2it:fix/updater-backup-and-locked-drag

Conversation

@fix2it

@fix2it fix2it commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Hi, and thank you for Claude Code Usage Monitor. I use it every day. While working on a personal fork I ran into two bugs that also exist on main, so here are small, self-contained fixes for both. Each one is a separate commit, so they are easy to review or to take one at a time.

1. Updater: a failed update can delete the only copy of the exe

Steps to reproduce

  1. Start an update while the new file cannot be copied over the installed exe (for example, the install directory turns read-only, or antivirus holds the file), and the restore of the old exe also fails.
  2. At that point the installed exe exists only as the .old backup next to it.
  3. Run the update again (or let the next retry iteration run).

Cause
replace_target_binary starts every attempt with remove_file(&backup_path). When the target is gone and the backup holds the previous version, that call deletes the last copy of the program. The restore error (rename(&backup_path, target)) was also ignored, so the loop kept going.

Change (src/updater.rs)

  • The backup is removed only while the target exe still exists. If the target is missing and a backup exists, the function stops and returns an error that names the backup path.
  • If restoring the backup fails, the function returns right away with an error that says where the previous version is kept.
  • The retry count and delay moved into replace_target_binary_with_retries so tests can run without the 30-second wait. replace_target_binary keeps the same behaviour (60 × 500 ms).

How to verify

  • cargo test updater: two new tests:
    • failed_replacement_never_deletes_the_only_copy_in_the_backup
    • failed_copy_restores_the_installed_binary

2. Widget: a locked widget dragged to the desktop disappears

Steps to reproduce

  1. Dock the widget in the taskbar and turn on Lock in taskbar.
  2. Drag the widget off the taskbar and drop it on the desktop.
  3. The widget vanishes. It is still running, but it sits behind other windows and the desktop.

Cause
In WM_LBUTTONUP, a drop outside the taskbar takes the locked branch. That branch re-embeds the drag popup as a taskbar child and calls position_at_taskbar. The window that was topmost during the drag ends up at the bottom of the z-order, so it is not visible.

Change (src/window.rs, src/window/message_loop.rs)

  • New helper release_taskbar_lock_for_desktop_drop: when the lock applies to the current placement, it turns lock_taskbar off.
  • The drop then takes the normal floating path. Settings are saved and the menu check follows the setting. A widget that is already floating keeps the user's lock preference.
  • Dropping onto the taskbar is unchanged.

I picked "the drop releases the lock" because the user has clearly moved the widget off the bar. If you would rather keep the widget pinned (and only fix the z-order), I'm happy to change the approach.

How to verify

  • cargo test desktop_drop_releases_taskbar_lock
  • Manual check: follow the steps above. The widget stays visible on the desktop and Lock in taskbar is unchecked in the menu.

Checks

cargo fmt, cargo test, cargo clippy --all-targets, and cargo build --release all pass on this branch.

Thanks again for your work on this project!

🤖 Generated with Claude Code

fix2it and others added 2 commits November 17, 2026 19:32
replace_target_binary removed the backup at the start of every attempt.
When the copy failed and restoring the backup failed too, the backup was
the only copy of the program, and the next attempt deleted it.

Drop the backup only while the target still exists, stop with an error
that names the backup path when it does not, and return at once when the
restore fails. Retries and delay are parameters so tests run fast.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… on the desktop

With "Lock in taskbar" on, dropping the widget outside the taskbar
re-embedded the drag popup into the taskbar. The window fell to the
bottom of the z-order and disappeared behind other windows.

A drop on the desktop now turns the lock off (only when it applies to
the current placement) and takes the normal floating path, so the
widget stays visible and the setting and menu check follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fix2it fix2it changed the title fix: keep the exe backup on a failed update; release the taskbar lock on a desktop drop fix: keep the backup exe when an update fails; release the taskbar lock on a desktop drop Nov 17, 2026
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