From a7f2826bb92d3bc63bfe71dd42ab70559980b4e4 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 27 Apr 2019 01:57:40 +0200 Subject: [PATCH] Fix: Do only check entries which are a ref We should not try to check entries that are not refs because this will always fail. And because we fail _hard_, the execution of the command fails on the first non-ref-entry and exits the program. Not good for a filter... :-) Signed-off-by: Matthias Beyer --- bin/core/imag-ref/src/main.rs | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/bin/core/imag-ref/src/main.rs b/bin/core/imag-ref/src/main.rs index e1973a30..bd9f6ed6 100644 --- a/bin/core/imag-ref/src/main.rs +++ b/bin/core/imag-ref/src/main.rs @@ -175,23 +175,24 @@ fn list_dead(rt: &Runtime) { .for_each(|id| { match rt.store().get(id.clone()).map_err_trace_exit_unwrap() { Some(entry) => { - let entry_path = entry - .as_ref_with_hasher::() - .get_path(&cfg) - .map_err_trace_exit_unwrap(); + let entry_ref = entry.as_ref_with_hasher::(); - if !entry_path.exists() { - if list_id { - writeln!(output, "{}", entry.get_location().local().display()) - } else if list_path { - writeln!(output, "{}", entry_path.display()) - } else { - unimplemented!() + if entry_ref.is_ref().map_err_trace_exit_unwrap() { // we only care if the entry is a ref + let entry_path = entry_ref.get_path(&cfg).map_err_trace_exit_unwrap(); + + if !entry_path.exists() { + if list_id { + writeln!(output, "{}", entry.get_location().local().display()) + } else if list_path { + writeln!(output, "{}", entry_path.display()) + } else { + unimplemented!() + } + .map_err(Error::from) + .map_err_trace_exit_unwrap(); + + let _ = rt.report_touched(entry.get_location()).unwrap_or_exit(); } - .map_err(Error::from) - .map_err_trace_exit_unwrap(); - - let _ = rt.report_touched(entry.get_location()).unwrap_or_exit(); } }