diff --git a/eden/fs/cli_rs/edenfs-client/src/checkout.rs b/eden/fs/cli_rs/edenfs-client/src/checkout.rs index 8f4fea5d0f..87fdf22713 100644 --- a/eden/fs/cli_rs/edenfs-client/src/checkout.rs +++ b/eden/fs/cli_rs/edenfs-client/src/checkout.rs @@ -319,24 +319,22 @@ impl CheckoutConfig { } /// Add a profile to the config (read the config file and write it back - /// with profile added). + /// with profile added). Returns true if we should fetch, false otherwise. pub fn activate_profile( &mut self, profile: &str, config_dir: PathBuf, force_fetch: &bool, - ) -> Result<()> { + ) -> Result { if let Some(profiles) = &mut self.profiles { if profiles.active.iter().any(|x| x == profile) { // The profile is already activated so we don't need to update the profile list, // but we want to return a success so we continue with the fetch if *force_fetch { - return Ok(()); + return Ok(true); } - return Err(EdenFsError::Other(anyhow!( - "{} is already an active prefetch profile", - profile - ))); + eprintln!("{} is already an active prefetch profile", profile); + return Ok(false); } profiles.push(profile); self.save_config(config_dir.clone()).with_context(|| { @@ -346,7 +344,7 @@ impl CheckoutConfig { ) })?; } - Ok(()) + Ok(true) } /// Switch on predictive prefetch profiles (read the config file and write diff --git a/eden/fs/cli_rs/edenfs-commands/src/prefetch_profile.rs b/eden/fs/cli_rs/edenfs-commands/src/prefetch_profile.rs index 63527b5b13..7294d27596 100644 --- a/eden/fs/cli_rs/edenfs-commands/src/prefetch_profile.rs +++ b/eden/fs/cli_rs/edenfs-commands/src/prefetch_profile.rs @@ -288,16 +288,23 @@ impl PrefetchCmd { let checkout_config = CheckoutConfig::parse_config(config_dir.clone()); let result = checkout_config .and_then(|mut config| config.activate_profile(profile_name, config_dir, force_fetch)); - if let Err(e) = result { - #[cfg(fbcode_build)] - { - sample.fail(&e.to_string()); + match result { + Ok(res) => { + #[cfg(fbcode_build)] send(sample.builder); + if !res { + return Ok(0); + } } - return Err(anyhow::Error::new(e)); - } - #[cfg(fbcode_build)] - send(sample.builder); + Err(e) => { + #[cfg(fbcode_build)] + { + sample.fail(&e.to_string()); + send(sample.builder); + } + return Err(anyhow::Error::new(e)); + } + }; let checkout = find_checkout(instance, &options.checkout).with_context(|| { anyhow!(