fix: persist deep link across launcher self-update restart#244
fix: persist deep link across launcher self-update restart#244mihakrajnc wants to merge 1 commit into
Conversation
On Windows, `update.install()` calls `std::process::exit(0)` inside the Tauri updater after launching the NSIS installer. This means the deep link preservation code added in dee45b5 (which pushes the URL into `env.args_os` and calls `tauri::process::restart`) never executes — it is dead code on Windows. The NSIS installer does pass current args via `/ARGS`, but URL-like deep links containing `?`, `&`, `=` may get mangled when passed unquoted through the NSIS command line. Fix: write the deep link URL to a plain text file (`deeplink-state.txt`) **before** calling `update.install()`, and read it back on startup as a fallback when no deep link is found in command-line args. The file is cleaned up after the deep link is consumed in the launch flow. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Windows and Mac build successful in Launcher Rust!! You can find a link to the downloadable artifact below.
|
NickKhalow
left a comment
There was a problem hiding this comment.
Please address the comments
| }; | ||
|
|
||
| // Clear persisted deep link file after consumption | ||
| Protocol::clear_file(); |
There was a problem hiding this comment.
Why do you delete the file only if deeplink opens via an existing instance ? Why do you keep the file if a new explorer instance is opened?
| } | ||
| } | ||
|
|
||
| pub fn save_to_file(deeplink: &DeepLink) { |
There was a problem hiding this comment.
those implementation specific functioned don't need to be public. Let's proceed with public interface consume_deeplink() -> Option<DeepLink> and try_assign_value will write to file. Public API surface can be much simplier.
There was a problem hiding this comment.
method should be named with try_ prefix based on it's intent. Since method doesn't return an explicit Result<T, E> that needs an explanation via naming.
| channel.send_silent(LauncherUpdate::InstallingUpdate.into()); | ||
|
|
||
| // Persist deeplink to file BEFORE install (install may call exit(0) on Windows) | ||
| if let Some(deeplink) = Protocol::value() { |
There was a problem hiding this comment.
Will be redundant with new API surface
|
|
||
| ## Commit Convention | ||
|
|
||
| Conventional Commits: `feat:`, `fix:`, `chore:`, `style:` with optional scopes like `(release)`, `(windows)`, `(macos)`, `(auto-auth)`. |
There was a problem hiding this comment.
We don't use style: convention. Where did you get that?
| info!("Loaded persisted deep link from {}", path.display()); | ||
| Some(content) | ||
| } | ||
| Ok(_) | Err(_) => None, |
There was a problem hiding this comment.
It shouldn't ignore errors and better to log them
| } | ||
| } | ||
|
|
||
| pub fn clear_file() { |
There was a problem hiding this comment.
method should be named with try_ prefix based on it's intent
Summary
update.install()callsstd::process::exit(0)in the Tauri updater, so the deep link preservation code added indee45b5never executes — it's dead code on Windows.deeplink-state.txt) beforeupdate.install()is called, and reads it back on startup as a fallback when no deep link is found in command-line args.Fixes the following issue in Explorer: decentraland/unity-explorer#7692
Context
When a user opens a deep link (e.g.
decentraland://...?local-scene=true&realm=localhost:8000) and the launcher also needs to self-update:exit(0)in updater prevents preservation code from running. NSIS/ARGSpassthrough may also mangle URL-like strings with?,&,=.install(), recovered on restart.on_open_urlhasn't fired yet.Changes
core/src/protocols.rs— Addedsave_to_file(),load_from_file(),clear_file()toProtocolcore/src/installs.rs— Addeddeeplink_state_path()helpersrc-tauri/src/lib.rs— Save deep link beforeupdate.install(); load from file as fallback insetup_deeplinkcore/src/flow.rs— Clear persisted file after deep link is consumedTest plan
cargo clippyandcargo testpass oncore/andsrc-tauri/deeplink-state.txtfile is cleaned up after the deep link is consumed🤖 Generated with Claude Code