diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2019-02-11 04:27:51 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2019-02-15 20:53:29 +0100 |
commit | 39d638daee34c8e7b78cfb48c9f2781872a6b45e (patch) | |
tree | efa45b5f006ae5bfeb9e0df4a7c272ebc00bd9bf | |
parent | 972cba7c31605928fe4c6149e779b27401da02f3 (diff) |
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>
-rw-r--r-- | bin/core/imag-ids/src/main.rs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/bin/core/imag-ids/src/main.rs b/bin/core/imag-ids/src/main.rs index 72c07b6a..b0b84199 100644 --- a/bin/core/imag-ids/src/main.rs +++ b/bin/core/imag-ids/src/main.rs @@ -118,23 +118,27 @@ fn main() { } }) .map(|id| if print_storepath { - id + (Some(rt.store().path()), id) } else { - id.without_base() + (None, id) }); let mut stdout = rt.stdout(); trace!("Got output: {:?}", stdout); - iterator.for_each(|id| { - let _ = rt.report_touched(&id).unwrap_or_exit(); // .map_err_trace_exit_unwrap(); - + iterator.for_each(|(storepath, id)| { + rt.report_touched(&id).unwrap_or_exit(); if !rt.output_is_pipe() { let id = id.to_str().map_err_trace_exit_unwrap(); trace!("Writing to {:?}", stdout); - writeln!(stdout, "{}", id) - .to_exit_code() - .unwrap_or_exit(); + + let result = if let Some(store) = storepath { + writeln!(stdout, "{}/{}", store.display(), id) + } else { + writeln!(stdout, "{}", id) + }; + + result.to_exit_code().unwrap_or_exit(); } }) } |