From e96fb536776e0dd12c4357b9a7f5318d63ac54d2 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 7 Oct 2018 10:56:56 +0200 Subject: [PATCH] Fix: Use "retrieve" instead of "create" when importing This fixes a bug where a re-import of the contacts directory failed because some entries already exist. With this change, one can import the contact directory after things changed in there and the imag database is updated accordingly, but not altered. So links and notes are persisting. For completeness: before, the workflow was to `cd $IMAG_RTP && git rm store/contacts -r && imag contact import /path/to/contacts` which is of course not optimal. Signed-off-by: Matthias Beyer --- bin/domain/imag-contact/src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/domain/imag-contact/src/main.rs b/bin/domain/imag-contact/src/main.rs index c8c033b0..a89a6b06 100644 --- a/bin/domain/imag-contact/src/main.rs +++ b/bin/domain/imag-contact/src/main.rs @@ -170,7 +170,7 @@ fn import(rt: &Runtime) { if path.is_file() { let _ = rt .store() - .create_from_path(&path) + .retrieve_from_path(&path) .map_err_trace_exit_unwrap(1); } else if path.is_dir() { for entry in WalkDir::new(path).min_depth(1).into_iter() { @@ -182,7 +182,7 @@ fn import(rt: &Runtime) { let pb = PathBuf::from(entry.path()); let _ = rt .store() - .create_from_path(&pb) + .retrieve_from_path(&pb) .map_err_trace_exit_unwrap(1); info!("Imported: {}", entry.path().to_str().unwrap_or("")); } else {