fix(desktop): probe legacy app-data dir at most once per install#2784
Open
mattalldianhr wants to merge 1 commit into
Open
fix(desktop): probe legacy app-data dir at most once per install#2784mattalldianhr wants to merge 1 commit into
mattalldianhr wants to merge 1 commit into
Conversation
`migrate_legacy_app_data_dir` ran on every launch and called `legacy_dir.exists()` on `xyz.block.sprout.app` — another app's container. On macOS that stat is itself gated by TCC, so it triggers the "would like to access data from other apps" consent prompt before the function bails. Users who never ran Sprout have no legacy dir at all, so the probe could never lead to a copy — it only produced a consent prompt on every single launch. Gate the probe behind a `.legacy-app-data-probed` marker written inside the current app-data dir. Placement is deliberate: unlike the reset sentinel in `reset.rs` (which lives in the parent so it survives a wipe), this marker must be wiped alongside `app_data_dir` so a genuine post-reset migration can still run. The marker is written *before* the probe so an unwritable marker skips probing rather than prompting forever. Extracts the body into `migrate_legacy_app_data_dir_at` so the behavior is testable without a Tauri AppHandle. Tests: first-run copy, no-reprobe once marked, marking when the legacy dir is absent, and re-running after a reset wipes the marker. Verified the no-reprobe test fails without the guard.
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
migrate_legacy_app_data_dirruns on every launch and callslegacy_dir.exists()on~/Library/Application Support/xyz.block.sprout.app— a different app's container. On macOS that stat is itself gated by TCC, so it triggers the "Buzz would like to access data from other apps" consent prompt before the function bails.For anyone who never ran Sprout there is no legacy dir at all, so the probe can never lead to a copy. It only produces a consent prompt, on every single launch, forever.
Implementation
Gate the probe behind a
.legacy-app-data-probedmarker written inside the current app-data dir.Two deliberate decisions:
Marker placement. Unlike the reset sentinel in
reset.rs— which lives in the app-data dir's parent so it survives the wipe — this marker goes insideapp_data_dir.run_boot_resetwipesapp_data_dirand the legacy dir together, which clears the marker, so a genuine post-reset migration can still run. Putting it in the parent would have permanently suppressed that path.Write-before-probe. The marker is written before the
exists()call. If it can't be written we skip the probe entirely rather than falling through. A missed migration is recoverable; an unkillable system prompt is not.The body is extracted into
migrate_legacy_app_data_dir_at(legacy_dir, current_dir)so the behavior is testable without a TauriAppHandle.Tests
Four regression tests in
migration_tests.rs:legacy_app_data_migration_copies_then_marks_probed— first run still migrateslegacy_app_data_migration_does_not_reprobe_after_marker— the actual fixlegacy_app_data_migration_marks_even_when_legacy_absent— the reported caselegacy_app_data_migration_reruns_after_marker_wiped— reset interaction preservedI verified these catch the bug rather than merely passing: temporarily disabling the guard makes
does_not_reprobe_after_markerfail, and restoring it makes it pass. The pre-existingreset::tests::test_legacy_app_data_removed_on_resetstill passes.How to test manually
On a machine with no
~/Library/Application Support/xyz.block.sprout.app:Notes
cargo fmtandcargo clippy --all-targetsare clean ondesktop/src-tauri.cargo test --manifest-path desktop/src-tauri/Cargo.toml. Note this build requires thebinaries/sidecars to be present.