From c17e584e524da18b5fa9970f027157d8b43f3629 Mon Sep 17 00:00:00 2001 From: Alexander Weiss Date: Mon, 2 Dec 2024 11:55:29 +0100 Subject: [PATCH] fix(backup): run hooks before checking backup source dir --- src/commands/backup.rs | 76 +++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/src/commands/backup.rs b/src/commands/backup.rs index 31dca3224..86f335af8 100644 --- a/src/commands/backup.rs +++ b/src/commands/backup.rs @@ -184,47 +184,47 @@ impl BackupCmd { } .to_indexed_ids()?; - let config_snapshot_sources: Vec<_> = snapshot_opts - .iter() - .map(|opt| -> Result<_> { - Ok(PathList::from_iter(&opt.sources) - .sanitize() - .with_context(|| { - format!( - "error sanitizing sources=\"{:?}\" in config file", - opt.sources - ) - })? - .merge()) - }) - .filter_map(|p| match p { - Ok(paths) => Some(paths), - Err(err) => { - warn!("{err}"); - None + let hooks = config.backup.hooks.with_context("backup"); + hooks.use_with(|| -> Result<_> { + let config_snapshot_sources: Vec<_> = snapshot_opts + .iter() + .map(|opt| -> Result<_> { + Ok(PathList::from_iter(&opt.sources) + .sanitize() + .with_context(|| { + format!( + "error sanitizing sources=\"{:?}\" in config file", + opt.sources + ) + })? + .merge()) + }) + .filter_map(|p| match p { + Ok(paths) => Some(paths), + Err(err) => { + warn!("{err}"); + None + } + }) + .collect(); + + let snapshot_sources = match (self.cli_sources.is_empty(), snapshot_opts.is_empty()) { + (false, _) => { + let item = PathList::from_iter(&self.cli_sources).sanitize()?; + vec![item] } - }) - .collect(); - - let snapshot_sources = match (self.cli_sources.is_empty(), snapshot_opts.is_empty()) { - (false, _) => { - let item = PathList::from_iter(&self.cli_sources).sanitize()?; - vec![item] - } - (true, false) => { - info!("using all backup sources from config file."); - config_snapshot_sources.clone() - } - (true, true) => { - bail!("no backup source given."); + (true, false) => { + info!("using all backup sources from config file."); + config_snapshot_sources.clone() + } + (true, true) => { + bail!("no backup source given."); + } + }; + if snapshot_sources.is_empty() { + return Ok(()); } - }; - if snapshot_sources.is_empty() { - return Ok(()); - } - let hooks = config.backup.hooks.with_context("backup"); - hooks.use_with(|| -> Result<_> { let mut is_err = false; for sources in snapshot_sources { let mut opts = self.clone();