-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Guard against concurrent cache writes on Windows #11007
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,8 +45,11 @@ pub async fn read_to_string_transcode(path: impl AsRef<Path>) -> std::io::Result | |
|
||
/// Create a symlink at `dst` pointing to `src`, replacing any existing symlink. | ||
/// | ||
/// On Windows, this uses the `junction` crate to create a junction point. | ||
/// Note because junctions are used, the source must be a directory. | ||
/// On Windows, this uses the `junction` crate to create a junction point. The | ||
/// operation is _not_ atomic, as we first delete the junction, then create a | ||
/// junction at the same path. | ||
/// | ||
/// Note that because junctions are used, the source must be a directory. | ||
Comment on lines
+48
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do i read this comment correctly that there is no way for us to make this atomic? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can try, but making it atomic doesn't solve the problem. We could still run into issues whereby we attempt to overwrite the file while it's open, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's good to know, i didn't think of that case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's somewhat tragic. I think we should still try to make this atomic though. |
||
#[cfg(windows)] | ||
pub fn replace_symlink(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> std::io::Result<()> { | ||
// If the source is a file, we can't create a junction | ||
|
@@ -79,6 +82,10 @@ pub fn replace_symlink(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> std::io: | |
} | ||
|
||
/// Create a symlink at `dst` pointing to `src`, replacing any existing symlink if necessary. | ||
/// | ||
/// On Unix, this method creates a temporary file, then moves it into place. | ||
/// | ||
/// TODO(charlie): Consider using the `rust-atomicwrites` crate. | ||
#[cfg(unix)] | ||
pub fn replace_symlink(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> std::io::Result<()> { | ||
// Attempt to create the symlink directly. | ||
|
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.
Can you extend the comment explaining the
[cfg(windows)]
?