Add example ref configuration for calendar

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2019-09-28 14:13:48 +02:00
parent 2e6df0e458
commit 61f71d67cc
2 changed files with 13 additions and 1 deletions

View file

@ -102,6 +102,14 @@ fn import(rt: &Runtime) {
.ok_or_else(|| format_err!("Configuration missing: {}", libimagentryref::reference::Config::LOCATION)) .ok_or_else(|| format_err!("Configuration missing: {}", libimagentryref::reference::Config::LOCATION))
.map_err_trace_exit_unwrap(); .map_err_trace_exit_unwrap();
// sanity check
debug!("Doing sanity check on config, to see whether the configuration required for importing is there");
if ref_config.get(collection_name).is_none() {
error!("Configuration missing: {}.{}", libimagentryref::reference::Config::LOCATION, collection_name);
::std::process::exit(1);
}
debug!("Starting import...");
scmd.values_of("filesordirs") scmd.values_of("filesordirs")
.unwrap() // save by clap .unwrap() // save by clap
.into_iter() .into_iter()
@ -115,7 +123,9 @@ fn import(rt: &Runtime) {
Err(e) => Some(Err(Error::from(e))), Err(e) => Some(Err(Error::from(e))),
Ok(fe) => { Ok(fe) => {
if fe.file_type().is_file() { if fe.file_type().is_file() {
Some(Ok(fe.into_path())) let path = fe.into_path();
trace!("Found file: {}", path.display());
Some(Ok(path))
} else { } else {
None // filter out directories None // filter out directories
} }
@ -127,6 +137,7 @@ fn import(rt: &Runtime) {
.flat_map(|it| it) // From Iter<Iter<Result<PathBuf>>> to Iter<Result<PathBuf>> .flat_map(|it| it) // From Iter<Iter<Result<PathBuf>>> to Iter<Result<PathBuf>>
.trace_unwrap_exit() //... to Iter<PathBuf> .trace_unwrap_exit() //... to Iter<PathBuf>
.map(|path| { .map(|path| {
trace!("Importing {}", path.display());
let v = rt.store().import_from_path(path, collection_name, &ref_config, force_override)?; let v = rt.store().import_from_path(path, collection_name, &ref_config, force_override)?;
Ok(v.into_iter() Ok(v.into_iter()
.filter_map(|result| if do_fail { .filter_map(|result| if do_fail {

View file

@ -353,6 +353,7 @@ execute_in_store = false
music = "/home/user/music" music = "/home/user/music"
mail = "/home/user/mail" mail = "/home/user/mail"
contacts = "/home/user/contacts" contacts = "/home/user/contacts"
calendars = "/home/user/calendars"
[mail] [mail]
# The name of the mail reference collection # The name of the mail reference collection