summaryrefslogtreecommitdiff
path: root/src/cmd/backup.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-02-03 09:11:49 +0200
committerLars Wirzenius <liw@liw.fi>2021-02-04 09:14:01 +0200
commita2adcb5a90c15b473a2fcf114555443fba8a20ce (patch)
tree7ec36f244daa105b0da774d6705ef736f9135f64 /src/cmd/backup.rs
parentbf08ea67ca035fc0e78364450599cefff7cd9bc6 (diff)
downloadobnam2-a2adcb5a90c15b473a2fcf114555443fba8a20ce.tar.gz
refactor: have per-module error enums
This means that a function that parses step bindings can't return an error that the document is missing a title. Such an error return would be nonsensical, and we use the Rust type system to prevent it, at a small cost of being a bit verbose. Additional benefit is that the library portion of Obnam doesn't return anyhow::Result values anymore.
Diffstat (limited to 'src/cmd/backup.rs')
-rw-r--r--src/cmd/backup.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/cmd/backup.rs b/src/cmd/backup.rs
index da7298f..a43a622 100644
--- a/src/cmd/backup.rs
+++ b/src/cmd/backup.rs
@@ -1,12 +1,13 @@
use crate::backup_run::BackupRun;
use crate::client::ClientConfig;
+use crate::error::ObnamError;
use crate::fsiter::FsIterator;
use crate::generation::NascentGeneration;
use log::info;
use std::time::SystemTime;
use tempfile::NamedTempFile;
-pub fn backup(config: &ClientConfig, buffer_size: usize) -> anyhow::Result<()> {
+pub fn backup(config: &ClientConfig, buffer_size: usize) -> Result<(), ObnamError> {
let runtime = SystemTime::now();
let run = BackupRun::new(config, buffer_size)?;
@@ -33,11 +34,11 @@ pub fn backup(config: &ClientConfig, buffer_size: usize) -> anyhow::Result<()> {
let mut new = NascentGeneration::create(&newname)?;
match genlist.resolve("latest") {
- None => {
+ Err(_) => {
info!("fresh backup without a previous generation");
new.insert_iter(iter.map(|entry| run.backup_file_initially(entry)))?;
}
- Some(old) => {
+ Ok(old) => {
info!("incremental backup based on {}", old);
let old = run.client().fetch_generation(&old, &oldname)?;
run.progress()