(
agent: &str,
src: &Path,
dst: &Path,
previous: Option<&Receipt>,
force: bool,
installed: &mut Vec<PathBuf>,
refreshed: &mut Vec<PathBuf>,
skipped: &mut Vec<SkippedFil
| 591 | /// Shared by [[file]], [[skill]], and [[repo-file]] entries. |
| 592 | #[allow(clippy::too_many_arguments)] |
| 593 | fn copy_one( |
| 594 | agent: &str, |
| 595 | src: &Path, |
| 596 | dst: &Path, |
| 597 | previous: Option<&Receipt>, |
| 598 | force: bool, |
| 599 | installed: &mut Vec<PathBuf>, |
| 600 | refreshed: &mut Vec<PathBuf>, |
| 601 | skipped: &mut Vec<SkippedFile>, |
| 602 | receipt_files: &mut Vec<ReceiptFile>, |
| 603 | ) -> AgentResult<()> { |
| 604 | let _ = agent; // used only in error context by callers |
| 605 | match install_decision(dst, previous, force)? { |
| 606 | Decision::Install => installed.push(dst.to_path_buf()), |
| 607 | Decision::Refresh => refreshed.push(dst.to_path_buf()), |
| 608 | // Merge only applies to [[repo-file]] (via copy_repo_file). For |
| 609 | // [[file]] and [[skill]], install_decision never returns Merge — |
| 610 | // treat as a refresh if it somehow occurs. |
| 611 | Decision::Merge => refreshed.push(dst.to_path_buf()), |
| 612 | Decision::Skip(reason) => { |
| 613 | skipped.push(SkippedFile { |
| 614 | dst: dst.to_path_buf(), |
| 615 | reason, |
| 616 | }); |
| 617 | // Keep protecting this file: preserve any prior receipt entry |
| 618 | // so a later --force still knows whether it was ours. |
| 619 | if let Some(old) = previous.and_then(|r| r.files.iter().find(|f| f.dst == dst)) { |
| 620 | receipt_files.push(old.clone()); |
| 621 | } |
| 622 | return Ok(()); |
| 623 | } |
| 624 | } |
| 625 | |
| 626 | if let Some(parent) = dst.parent() { |
| 627 | std::fs::create_dir_all(parent)?; |
| 628 | } |
| 629 | std::fs::copy(src, dst)?; |
| 630 | receipt_files.push(ReceiptFile { |
| 631 | blake3: hash_file(dst)?, |
| 632 | dst: dst.to_path_buf(), |
| 633 | }); |
| 634 | Ok(()) |
| 635 | } |
| 636 | |
| 637 | /// Copy a [[repo-file]] into the repo root, with merge support. |
| 638 | /// |
no test coverage detected