-
Notifications
You must be signed in to change notification settings - Fork 5
feat: Add hard_link_or_copy function to MartianRover #419
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
base: master
Are you sure you want to change the base?
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 |
---|---|---|
|
@@ -494,6 +494,23 @@ impl MartianRover { | |
Ok(()) | ||
} | ||
} | ||
|
||
/// Creates a hard link (falls back to copy) to the given MartianFileType file | ||
/// within the rover's file directory | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `src` - The path to the MartianFileType file | ||
/// | ||
/// # Returns | ||
/// | ||
/// * The path of the newly created link | ||
pub fn hard_link_or_copy<M: MartianFileType>(&self, src: &M) -> Result<M, Error> { | ||
let stem = src.as_ref().file_name().expect("Could not get file name."); | ||
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. To aid in debugging, please include the full path contents in the expect message. |
||
let dst: M = self.make_path(stem); | ||
std::fs::hard_link(src, &dst).or_else(|_| std::fs::copy(src, &dst).map(|_| ()))?; | ||
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. Same thing here; we should include the input path as context in any error message emanating from here. |
||
Ok(dst) | ||
} | ||
} | ||
|
||
/// Two different kinds of marian stages. `MainOnly` stages only have a | ||
|
Uh oh!
There was an error while loading. Please reload this page.