Decide what to do with a destination that may already exist.
(dst: &Path, previous: Option<&Receipt>, force: bool)
| 497 | |
| 498 | /// Decide what to do with a destination that may already exist. |
| 499 | fn install_decision(dst: &Path, previous: Option<&Receipt>, force: bool) -> AgentResult<Decision> { |
| 500 | if !dst.exists() { |
| 501 | return Ok(Decision::Install); |
| 502 | } |
| 503 | let recorded = previous.and_then(|r| r.recorded_hash(dst)); |
| 504 | match recorded { |
| 505 | // Ours and untouched since install → safe to refresh. |
| 506 | Some(hash) if hash == hash_file(dst)? => Ok(Decision::Refresh), |
| 507 | // Ours but the user changed it → hands off unless forced. |
| 508 | Some(_) if !force => Ok(Decision::Skip(SkipReason::UserModified)), |
| 509 | // Not ours → hands off unless forced. |
| 510 | None if !force => Ok(Decision::Skip(SkipReason::UserFile)), |
| 511 | _ => Ok(Decision::Refresh), |
| 512 | } |
| 513 | } |
| 514 | |
| 515 | /// Decide what to do with a [[repo-file]] destination. Unlike [[file]] and |
| 516 | /// [[skill]], a repo-file that exists but isn't ours can be *merged* — the |
no test coverage detected