Fix background updater - #54
Conversation
WalkthroughThe changes consist of two parts. First, a new dependency Changes
Sequence Diagram(s)sequenceDiagram
participant App as Tauri App
participant Checker as Update Checker (lib.rs)
participant State as Global State
App->>Checker: Invoke check_for_updates()
Checker->>State: Read CURRENT_VERSION & UPDATE_DOWNLOADED
alt Update already downloaded?
Checker-->>App: Log "Update already downloaded" and exit
else
Checker->>Checker: Compare CURRENT_VERSION with available update version
Checker->>State: Update CURRENT_VERSION and set UPDATE_DOWNLOADED to true
Checker-->>App: Proceed with update installation/notification
end
Poem
Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Deploying maple with
|
| Latest commit: |
f57e1cc
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://ef7adfd1.maple-ca8.pages.dev |
| Branch Preview URL: | https://background-downloader.maple-ca8.pages.dev |
There was a problem hiding this comment.
PR Summary
This PR enhances the application's update mechanism by preventing redundant downloads and notifications for the same version updates.
- Added
once_celldependency (v1.18.0) infrontend/src-tauri/Cargo.tomlfor thread-safe lazy initialization - Implemented global state tracking with
UPDATE_DOWNLOADED(AtomicBool) andCURRENT_VERSION(Mutex) infrontend/src-tauri/src/lib.rs - Added version comparison logic to skip re-downloading already downloaded updates
- Improved update dialog with more descriptive title "Maple Update" and clearer user messaging
- Implemented proper mutex locking with error handling for thread-safe version tracking
Greptile AI
2 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
frontend/src-tauri/src/lib.rs (1)
230-248: Effective early return logic prevents redundant downloads.The implementation correctly checks if the specific version has already been downloaded before proceeding with the download process. This prevents unnecessary network traffic and improves the user experience by avoiding duplicate downloads of the same update.
One minor suggestion: consider adding a debug log at the beginning of this function to record the update version being checked against the current version for easier troubleshooting.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
frontend/src-tauri/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (2)
frontend/src-tauri/Cargo.toml(1 hunks)frontend/src-tauri/src/lib.rs(5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: build-macos (universal-apple-darwin)
- GitHub Check: build-linux
- GitHub Check: Cloudflare Pages
🔇 Additional comments (6)
frontend/src-tauri/Cargo.toml (1)
32-32: Appropriate dependency addition for global state management.The addition of
once_cell = "1.18.0"is appropriate for implementing thread-safe lazy initialization of static variables, which will be used to prevent redundant update downloads and notifications.frontend/src-tauri/src/lib.rs (5)
198-209: Good implementation of global state for update tracking.The introduction of global static variables using
once_celland atomic types provides a thread-safe mechanism to track update status across multiple update check operations. TheAtomicBoolandMutexwrappers ensure thread safety when accessing these shared state variables from different async tasks.
275-293: Good state management after successful update installation.The code properly updates the global state after a successful update installation, storing the version information and preventing redundant notifications for the same update. This ensures users aren't repeatedly prompted about the same update.
56-56: Clean code formatting improvement.Removal of unnecessary blank lines improves code readability.
Also applies to: 62-62, 67-67
309-309: Clear and concise dialog title.The dialog title change to "Maple Update" provides better context to the user about the nature of the notification.
56-70: Verify update check behavior with hourly interval.The hourly update check mechanism will continue to run as before, but now with the added benefit of skipping redundant downloads. However, it might be worth considering whether updates should be re-checked after the application has been running for a while, even if an update was previously downloaded but not installed.
Consider if this edge case needs handling: if a user ignores an update notification and keeps the application running for days, should the application eventually re-prompt them about the pending update?
…go-audit-maple-proxy Security: enforce daily RustSec advisory checks
Summary by CodeRabbit