pub fn apply_install(plan: &InstallPlan, root: &Path) -> Result<FileManifest>Expand description
Applies an install plan into root, copying files and recording what was
written.
root is the caller-supplied profile/loader root. Parent directories are
created as needed. Files tracked as none (shared config) are written only if
absent and are never recorded, so a user’s edits survive reinstalls and they are
never auto-removed; all other files are (over)written and recorded in the
returned FileManifest (paths relative to root).
The apply is all-or-nothing: if any entry fails, every file this call created
is removed before the error is returned — along with any directory tree this
call newly created (now left empty) — so a partial install leaves root as it
found it, with no untracked files or empty directories behind.
For a none-tracked (shared config) destination that already exists — a
regular file or a symlink the user planted — the entry is skipped and left
untouched, so a user’s edits (or their symlinked config) survive. For a
tracked destination, a symlink already sitting there is refused rather than
followed, so a pre-planted leaf link cannot redirect the write. This is
best-effort: it inspects the final path component only (not symlinked parent
directories) and is not race-free against a concurrent attacker mutating
root mid-install.