fix: report what happened instead of losing it

This commit is contained in:
2026-09-09 11:59:58 +00:00
parent 75f293ce36
commit b4b6d5918f
7 changed files with 168 additions and 33 deletions

View File

@@ -28,7 +28,7 @@ pub fn add(ctx: &Ctx, paths: &[PathBuf], force: bool, store: Option<&Path>) -> R
let mut failed = 0;
for path in paths {
if let Err(e) = link_one(ctx, &repo, path, force, &report) {
note!(ctx, "error: {e:#}");
warning!("{e:#}");
failed += 1;
}
}
@@ -44,11 +44,11 @@ pub fn restore(ctx: &Ctx, paths: &[PathBuf], all: bool, store: Option<&Path>) ->
let repo = Repo::discover(ctx, store)?;
let report = Report::new(&repo);
let stored = match (all, paths) {
(true, []) => stored_paths(&repo, &repo.store)?,
(true, _) => bail!("--all restores everything, so it takes no paths"),
(false, []) => bail!("name a path to restore, or pass --all"),
(false, paths) => paths.iter().cloned().map(|p| (p, Stored::Linked)).collect(),
// clap requires one or the other and refuses both, so only the two real
// cases are left here
let stored = match all {
true => stored_paths(&repo, &repo.store)?,
false => paths.iter().cloned().map(|p| (p, Stored::Linked)).collect(),
};
// only a linked path can be moved back; the store can hold orphans too
@@ -88,7 +88,7 @@ pub fn restore(ctx: &Ctx, paths: &[PathBuf], all: bool, store: Option<&Path>) ->
let mut failed = 0;
for path in &linked {
if let Err(e) = restore_one(ctx, &repo, path, &report) {
note!(ctx, "error: {e:#}");
warning!("{e:#}");
failed += 1;
}
}