Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 38 additions & 38 deletions src/commands/backup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down