diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-03-27 11:03:07 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-03-27 11:03:07 +0200 |
commit | 5af0888b60ba124d537efda829a5ba3f7130d07a (patch) | |
tree | e3bf1a2544258c6452236eae7532189b2e6e7303 /src/backup_run.rs | |
parent | 08c2de031ea9556711673901f36675cba7744e26 (diff) | |
download | obnam2-5af0888b60ba124d537efda829a5ba3f7130d07a.tar.gz |
refactor: don't return a Result from function that can't fail
Diffstat (limited to 'src/backup_run.rs')
-rw-r--r-- | src/backup_run.rs | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/backup_run.rs b/src/backup_run.rs index a1faafd..5e26da4 100644 --- a/src/backup_run.rs +++ b/src/backup_run.rs @@ -65,7 +65,13 @@ impl<'a> InitialBackup<'a> { let path = &entry.pathbuf(); info!("backup: {}", path.display()); self.progress.found_live_file(path); - backup_file(&self.client, &entry, &path, self.buffer_size, Reason::IsNew) + Ok(backup_file( + &self.client, + &entry, + &path, + self.buffer_size, + Reason::IsNew, + )) } } } @@ -130,9 +136,13 @@ impl<'a> IncrementalBackup<'a> { Reason::IsNew | Reason::Changed | Reason::GenerationLookupError - | Reason::Unknown => { - backup_file(&self.client, &entry, &path, self.buffer_size, reason) - } + | Reason::Unknown => Ok(backup_file( + &self.client, + &entry, + &path, + self.buffer_size, + reason, + )), Reason::Unchanged | Reason::Skipped | Reason::FileError => { let fileno = old.get_fileno(&entry.pathbuf())?; let ids = if let Some(fileno) = fileno { @@ -166,13 +176,13 @@ fn backup_file( path: &Path, chunk_size: usize, reason: Reason, -) -> BackupResult<(FilesystemEntry, Vec<ChunkId>, Reason)> { +) -> (FilesystemEntry, Vec<ChunkId>, Reason) { let ids = client.upload_filesystem_entry(&entry, chunk_size); match ids { Err(err) => { warn!("error backing up {}, skipping it: {}", path.display(), err); - Ok((entry.clone(), vec![], Reason::FileError)) + (entry.clone(), vec![], Reason::FileError) } - Ok(ids) => Ok((entry.clone(), ids, reason)), + Ok(ids) => (entry.clone(), ids, reason), } } |