MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / install_decision

Function install_decision

atomic-agent/src/integrations/install.rs:273–287  ·  view source on GitHub ↗

Decide what to do with a destination that may already exist.

(dst: &Path, previous: Option<&Receipt>, force: bool)

Source from the content-addressed store, hash-verified

271
272/// Decide what to do with a destination that may already exist.
273fn install_decision(dst: &Path, previous: Option<&Receipt>, force: bool) -> AgentResult<Decision> {
274 if !dst.exists() {
275 return Ok(Decision::Install);
276 }
277 let recorded = previous.and_then(|r| r.recorded_hash(dst));
278 match recorded {
279 // Ours and untouched since install → safe to refresh.
280 Some(hash) if hash == hash_file(dst)? => Ok(Decision::Refresh),
281 // Ours but the user changed it → hands off unless forced.
282 Some(_) if !force => Ok(Decision::Skip(SkipReason::UserModified)),
283 // Not ours → hands off unless forced.
284 None if !force => Ok(Decision::Skip(SkipReason::UserFile)),
285 _ => Ok(Decision::Refresh),
286 }
287}
288
289/// Expand a leading `~` in a destination path.
290fn expand_dst(dst: &str) -> AgentResult<PathBuf> {

Callers 1

install_from_dirFunction · 0.85

Calls 3

hash_fileFunction · 0.85
existsMethod · 0.45
recorded_hashMethod · 0.45

Tested by

no test coverage detected