summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-08-09 10:51:53 +0300
committerLars Wirzenius <liw@liw.fi>2021-08-16 13:17:56 +0300
commit45a3c7109a03ef8466b8e94ef4aefb21de16bd0c (patch)
tree75a5075021a9162524e29ceca18dedae9eebc423
parentc2e9cd7865439ab5f0ec0b9761be6027bee880bb (diff)
downloadobnam2-45a3c7109a03ef8466b8e94ef4aefb21de16bd0c.tar.gz
refactor for clarity
Sponsored-by: author
-rw-r--r--src/backup_run.rs60
1 files changed, 30 insertions, 30 deletions
diff --git a/src/backup_run.rs b/src/backup_run.rs
index f78a83b..5aa9e58 100644
--- a/src/backup_run.rs
+++ b/src/backup_run.rs
@@ -213,7 +213,7 @@ impl<'a> BackupRun<'a> {
let reason = self.policy.needs_backup(old, &entry.inner);
match reason {
Reason::IsNew | Reason::Changed | Reason::GenerationLookupError | Reason::Unknown => {
- Ok(backup_one_entry(self.client, &entry, path, self.buffer_size, reason).await)
+ Ok(self.backup_one_entry(&entry, path, reason).await)
}
Reason::Unchanged | Reason::Skipped | Reason::FileError => {
let fileno = old.get_fileno(&entry.inner.pathbuf())?;
@@ -236,6 +236,35 @@ impl<'a> BackupRun<'a> {
}
}
+ async fn backup_one_entry(
+ &self,
+ entry: &AnnotatedFsEntry,
+ path: &Path,
+ reason: Reason,
+ ) -> FsEntryBackupOutcome {
+ let ids = self
+ .client
+ .upload_filesystem_entry(&entry.inner, self.buffer_size)
+ .await;
+ match ids {
+ Err(err) => {
+ warn!("error backing up {}, skipping it: {}", path.display(), err);
+ FsEntryBackupOutcome {
+ entry: entry.inner.clone(),
+ ids: vec![],
+ reason: Reason::FileError,
+ is_cachedir_tag: entry.is_cachedir_tag,
+ }
+ }
+ Ok(ids) => FsEntryBackupOutcome {
+ entry: entry.inner.clone(),
+ ids,
+ reason,
+ is_cachedir_tag: entry.is_cachedir_tag,
+ },
+ }
+ }
+
fn found_live_file(&self, path: &Path) {
if let Some(progress) = &self.progress {
progress.found_live_file(path);
@@ -248,32 +277,3 @@ impl<'a> BackupRun<'a> {
}
}
}
-
-async fn backup_one_entry(
- client: &AsyncBackupClient,
- entry: &AnnotatedFsEntry,
- path: &Path,
- chunk_size: usize,
- reason: Reason,
-) -> FsEntryBackupOutcome {
- let ids = client
- .upload_filesystem_entry(&entry.inner, chunk_size)
- .await;
- match ids {
- Err(err) => {
- warn!("error backing up {}, skipping it: {}", path.display(), err);
- FsEntryBackupOutcome {
- entry: entry.inner.clone(),
- ids: vec![],
- reason: Reason::FileError,
- is_cachedir_tag: entry.is_cachedir_tag,
- }
- }
- Ok(ids) => FsEntryBackupOutcome {
- entry: entry.inner.clone(),
- ids,
- reason,
- is_cachedir_tag: entry.is_cachedir_tag,
- },
- }
-}