mirror of
https://github.com/rustic-rs/rustic.git
synced 2025-10-26 11:18:51 +00:00
fix(commands): run backup hooks before checking source dir (#1374)
closes #1373 Co-authored-by: simonsan <14062932+simonsan@users.noreply.github.com>
This commit is contained in:
parent
852635e25c
commit
f14a8bbc57
@ -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
|
||||
}
|
||||
})
|
||||
.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.");
|
||||
}
|
||||
};
|
||||
if snapshot_sources.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
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]
|
||||
}
|
||||
(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(());
|
||||
}
|
||||
|
||||
let mut is_err = false;
|
||||
for sources in snapshot_sources {
|
||||
let mut opts = self.clone();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user