Skip to content
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

feat: Add hard_link_or_copy function to MartianRover #419

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sreenathkrishnan
Copy link
Member

No description provided.

@macklin-10x macklin-10x self-requested a review October 30, 2023 22:45
Copy link
Collaborator

@macklin-10x macklin-10x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once the path is included in the error messages.

///
/// * 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.");
Copy link
Collaborator

Choose a reason for hiding this comment

The 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.

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.");
let dst: M = self.make_path(stem);
std::fs::hard_link(src, &dst).or_else(|_| std::fs::copy(src, &dst).map(|_| ()))?;
Copy link
Collaborator

Choose a reason for hiding this comment

The 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants