Skip to main content

apply_import

Function apply_import 

Source
pub fn apply_import(project_root: &Path, plan: &ImportPlan) -> ImportReport
Expand description

Execute a plan, creating only the files it marked ImportAction::Copy.

Why: taking the plan as an ARGUMENT (rather than recomputing it) is what makes --dry-run meaningful — the operator authorises the exact list they read. What: creates each target’s parent directory and copies the file, in plan order. Returns the ImportReport. A copy that fails mid-run is reported as a refusal with the I/O error and does not abort the remaining entries, so one bad file cannot leave the import half-done with no record of what landed. Test: paths::import_tests::apply_creates_only_the_planned_files, paths::import_tests::apply_is_idempotent, paths::import_tests::swapped_target_dir_never_reaches_the_victim.