Adapt for new StoreId API

When printing the storepath with the ID (when requested by the user), we
have to ask the store for its path.

This is a rather naive implementation which could be improved by only
checking for a boolean in the last iteration and then use a prepared
variable, rather than making the storepath part of the iterator.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2019-02-11 04:27:51 +01:00
parent 972cba7c31
commit 39d638daee
1 changed files with 12 additions and 8 deletions

View File

@ -118,23 +118,27 @@ fn main() {
} }
}) })
.map(|id| if print_storepath { .map(|id| if print_storepath {
id (Some(rt.store().path()), id)
} else { } else {
id.without_base() (None, id)
}); });
let mut stdout = rt.stdout(); let mut stdout = rt.stdout();
trace!("Got output: {:?}", stdout); trace!("Got output: {:?}", stdout);
iterator.for_each(|id| { iterator.for_each(|(storepath, id)| {
let _ = rt.report_touched(&id).unwrap_or_exit(); // .map_err_trace_exit_unwrap(); rt.report_touched(&id).unwrap_or_exit();
if !rt.output_is_pipe() { if !rt.output_is_pipe() {
let id = id.to_str().map_err_trace_exit_unwrap(); let id = id.to_str().map_err_trace_exit_unwrap();
trace!("Writing to {:?}", stdout); trace!("Writing to {:?}", stdout);
writeln!(stdout, "{}", id)
.to_exit_code() let result = if let Some(store) = storepath {
.unwrap_or_exit(); writeln!(stdout, "{}/{}", store.display(), id)
} else {
writeln!(stdout, "{}", id)
};
result.to_exit_code().unwrap_or_exit();
} }
}) })
} }