-
Notifications
You must be signed in to change notification settings - Fork 2
feat: always set certain important variables automatically #1060
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
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 |
|---|---|---|
|
|
@@ -208,18 +208,40 @@ pub fn hardlink_dir_contents(src: &Path, dst: &Path) -> Result<(), HardlinkError | |
| } else if metadata.is_file() { | ||
| match fs::hard_link(&path, &dst_path) { | ||
| Ok(()) => Ok(()), | ||
| Err(e) => { | ||
| if e.kind() == std::io::ErrorKind::AlreadyExists { | ||
| Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => { | ||
| warn!( | ||
| "Not linking {} => {}, already exists", | ||
| path.display(), | ||
| dst_path.display() | ||
| ); | ||
| Ok(()) | ||
| } | ||
| // The cache and destination can live on different filesystems | ||
| // (e.g. a per-VM `/state` volume vs. the rootfs holding | ||
| // `/home`), where hardlinks are impossible (`EXDEV`). Fall back | ||
| // to a copy so materialization still succeeds — slower and no | ||
| // longer deduplicated, but correct. | ||
| Err(e) if e.kind() == std::io::ErrorKind::CrossesDevices => { | ||
| // Every file in a cross-device tree hits EXDEV, so warn only | ||
| // on the first — a per-file log would flood with thousands | ||
| // of identical lines. Once-per-process is enough: the cause | ||
| // is a fixed filesystem-layout fact, not a per-file | ||
| // condition. | ||
| use std::sync::atomic::{AtomicBool, Ordering}; | ||
| static WARNED: AtomicBool = AtomicBool::new(false); | ||
| if !WARNED.swap(true, Ordering::Relaxed) { | ||
| warn!( | ||
| "Not linking {} => {}, already exists", | ||
| "Copying instead of hardlinking: cache and \ | ||
| destination are on different filesystems; further \ | ||
| cross-device copies this run are silent (first: {} \ | ||
| => {})", | ||
| path.display(), | ||
| dst_path.display() | ||
| ); | ||
| Ok(()) | ||
| } else { | ||
| Err(e) | ||
| } | ||
| fs::copy(&path, &dst_path).map(|_| ()) | ||
|
Member
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. Im also not sure how I feel about this, maybe we are far enough along that its better to be slow and fallback to a copy, but also my other thought is this might mask when your paths are wrong
Member
Author
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 a good point. This is really only required for nested sandboxes, and there may be a better way. We should probably change it to be a preference, but I'll cut an issue for it given timing. |
||
| } | ||
| Err(e) => Err(e), | ||
| } | ||
| .map_err(|e| HardlinkError::HardlinkFailed(path.to_path_buf(), dst_path, e))?; | ||
| } else if metadata.is_symlink() { | ||
|
|
||
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.
Statics make me sad but I guess theres no way to do this cleaner without it being more verbose than its worth
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.
Yeah, I don't really like it either. I don't think we want the log spammed with every single file being copied though. There's probably a better way to do this, but we don't have a ton of time today.