Repository navigation
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
2 of 3 tasks
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.
What?
Recent-files saves for a project now run one at a time, and each save writes the project's current list. This stops the
rename failed: No such file or directorywarnings from #372, and an older list can no longer be the last one written torecent-files.json.Why?
recent_files_push,recent_files_renameandrecent_files_cleareach start the save withtokio::task::spawn_blockingand don't wait for it, so a burst of pushes (like the one at startup in #372) saves several times at once. Every save writes the same<project>/.atlas/recent-files.json.tmpand then renames it, so one save can rename another's temp file away. The second rename then fails with ENOENT. As @ik0zy worked out on the issue,create_dir_allruns first, so a missing directory isn't the cause. Each save also wrote the list it captured when it was spawned, and the blocking pool doesn't keep them in order, so an older list could finish last and overwrite a newer one on disk.No new dependencies.
parking_lotis already a dependency ofsrc-tauri.How?
save_to_diskreturns aResultwith the same messages it used to log (mkdir failed,write tmp failed,rename failed,serialize failed).save_latesttakes a staticSAVE_LOCK, reads the project's list under it, and saves that. Because the list is read inside the lock, the save that runs last writes the newest list.persistcallssave_latestand logs any error toatlas::recent_files, as before.itemshandle topersistinstead of a copy of the list.overlapping_saves_all_succeed_and_the_newest_list_wins: 16 threads each add an entry and save 25 times. Every save must succeed, the file on disk must equal the in-memory list, and no.tmpfile may be left over. Without the lock, saves fail with ENOENT on every run.Fixes #372
Checklist
I couldn't build the whole Tauri app on my Linux machine, so I haven't run the change in a window. I tested the changed functions on their own instead. I copied them unchanged (only
atlas_profile::dir_inand thetracingcall were swapped for local stand-ins) into a scratch crate with the sameparking_lotversion. There the new test passed 6/6 runs, and with the lock removed it failed every run withrename failed: No such file or directory. Clippy with the workspace deny list and the repoclippy.tomlis clean, and so isrustfmt --check. CI'scargo test --liband clippy forsrc-tauriwill run the real build.