summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlexander Batischev <eual.jp@gmail.com>2021-08-03 16:01:10 +0300
committerAlexander Batischev <eual.jp@gmail.com>2021-08-03 16:16:26 +0300
commit34bbdc7fc0ad76105146ccb2e62be1ad6164f7ef (patch)
tree020ba903d427491df06a9586a06e52132caa2f03 /src
parent4c6206a2cb1f8c1efba9fd08a4d6b4fa7d09a6dc (diff)
downloadobnam2-34bbdc7fc0ad76105146ccb2e62be1ad6164f7ef.tar.gz
fix: do not overlap "download" and "incremental" progress bars
The problem is the same as #101, except this time it affected a different set of progress bars. It was introduced in e6147a3b7b58b151fb7ad9b1f748e0a666f271de. This commit postpones the creation of "incremental" progress bar until after we've fetched the previous generation. This avoids showing both progress bars at once.
Diffstat (limited to 'src')
-rw-r--r--src/backup_run.rs25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/backup_run.rs b/src/backup_run.rs
index dee1d11..7172201 100644
--- a/src/backup_run.rs
+++ b/src/backup_run.rs
@@ -15,7 +15,7 @@ pub struct BackupRun<'a> {
client: &'a BackupClient,
policy: BackupPolicy,
buffer_size: usize,
- progress: BackupProgress,
+ progress: Option<BackupProgress>,
}
#[derive(Debug, thiserror::Error)]
@@ -54,7 +54,7 @@ impl<'a> BackupRun<'a> {
client,
policy: BackupPolicy::default(),
buffer_size: config.chunk_size,
- progress: BackupProgress::initial(),
+ progress: Some(BackupProgress::initial()),
})
}
@@ -66,7 +66,7 @@ impl<'a> BackupRun<'a> {
client,
policy: BackupPolicy::default(),
buffer_size: config.chunk_size,
- progress: BackupProgress::incremental(),
+ progress: None,
})
}
@@ -85,8 +85,11 @@ impl<'a> BackupRun<'a> {
}
Some(genid) => {
let old = self.fetch_previous_generation(genid, oldname)?;
- self.progress
- .files_in_previous_generation(old.file_count()? as u64);
+
+ let progress = BackupProgress::incremental();
+ progress.files_in_previous_generation(old.file_count()? as u64);
+ self.progress = Some(progress);
+
Ok(old)
}
}
@@ -104,7 +107,9 @@ impl<'a> BackupRun<'a> {
}
pub fn finish(&self) {
- self.progress.finish();
+ if let Some(progress) = &self.progress {
+ progress.finish();
+ }
}
pub fn backup_roots(
@@ -192,11 +197,15 @@ impl<'a> BackupRun<'a> {
}
fn found_live_file(&self, path: &Path) {
- self.progress.found_live_file(path);
+ if let Some(progress) = &self.progress {
+ progress.found_live_file(path);
+ }
}
fn found_problem(&self) {
- self.progress.found_problem();
+ if let Some(progress) = &self.progress {
+ progress.found_problem();
+ }
}
}