Skip to content

Commit

Permalink
rust-remove: implement Display for RemoveContext
Browse files Browse the repository at this point in the history
Summary: so I can save some typing when I need to dump the path to logging.

Reviewed By: MichaelCuevas

Differential Revision: D64862165

fbshipit-source-id: 8f312d58dd3b1196f8afc6b283f0434453715af3
  • Loading branch information
lXXXw authored and facebook-github-bot committed Oct 26, 2024
1 parent 62401f2 commit 7304cae
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions eden/fs/cli_rs/edenfs-commands/src/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ impl RemoveContext {
}
}

impl fmt::Display for RemoveContext {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.canonical_path.display())
}
}

#[derive(Debug)]
struct SanityCheck {}
impl SanityCheck {
Expand Down Expand Up @@ -87,24 +93,18 @@ impl Determination {
let path = context.canonical_path.as_path();

if path.is_file() {
debug!("path {} determined to be a regular file", path.display());
debug!("path {} determined to be a regular file", context);
return Ok(Some(State::RegFile(RegFile {})));
}

if !path.is_dir() {
return Err(anyhow!(format!(
"{} is not a file or a directory",
path.display()
)));
return Err(anyhow!(format!("{} is not a file or a directory", context)));
}

debug!("{} is determined as a directory", path.display());
debug!("{} is determined as a directory", context);

if self.is_active_eden_mount(context) {
debug!(
"path {} is determined to be an active eden mount",
path.display()
);
debug!("path {} is determined to be an active eden mount", context);

return Ok(Some(State::ActiveEdenMount(ActiveEdenMount {})));
}
Expand All @@ -122,10 +122,7 @@ impl Determination {
match unix_eden_dot_dir_path.canonicalize() {
Ok(resolved_path) => resolved_path == context.canonical_path,
Err(_) => {
warn!(
"{} is not an active eden mount",
context.canonical_path.display()
);
warn!("{} is not an active eden mount", context);
false
}
}
Expand Down

0 comments on commit 7304cae

Please sign in to comment.