-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Use TempDir for copied lockfiles
#20290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| "const_generics", | ||
| ] } | ||
| smol_str = "0.3.2" | ||
| temp-dir = "0.1.16" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I chose this crate because it uses short, safe Rust codes and has no deps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL temp-dir (besides tempdir, which is very popular, and tempfile, which is unmaintained).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| _temp_dir_guard = temp_dir::TempDir::new().ok(); | ||
| let target_lockfile = _temp_dir_guard | ||
| .and_then(|tmp| tmp.path().join("Cargo.lock").try_into().ok()) | ||
| .unwrap_or_else(|| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think failures on creating TempDir or converting it to Utf8PathBuf would be quite rare, but copied disambiguation from #20244 into this fallback anyway
| if let Some(lockfile) = lockfile_path { | ||
| let target_lockfile = | ||
| target_dir.join("rust-analyzer").join("metadata").join(kind).join("Cargo.lock"); | ||
| _temp_dir_guard = temp_dir::TempDir::new().ok(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we set a prefix here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's not necessary but having one would be good to some curious people who look into their /tmp/. Do you have some recommendations for prefix string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something with rust-analyzer or r-a? :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do have one for the proc-macro server already I think on windows (where we copy the proc macro dylibs)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah well, doesn't matter I guess as that is proc-macro specific
| to.push("rust-analyzer-proc-macros"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I just found that we also have a RemoveFileOnDrop for Windows there as well 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note as an aside but RemoveFileOnDrop shouldn't be a thing. Windows has file creation flags to mark them as to be deleted once all OS handles are dropped which we should be using instead I think.
e882f86 to
d5379d3
Compare
Fixes #20189 and closes #20244 and fixes #20113