fix: report what happened instead of losing it
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user