diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-04-06 06:41:06 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-04-06 06:41:06 +0000 |
commit | 2d6c1c81bfb1c0be8dfaced1c70e825e46c66430 (patch) | |
tree | ecdc94e803126946809c45ba5eca5d483cfebe76 | |
parent | 596d89380fb2295446cb6cde3b7c41d56d8ba22e (diff) | |
parent | ab2432645aa99bc77632a5f4d497f1b6ee65ff92 (diff) | |
download | obnam2-2d6c1c81bfb1c0be8dfaced1c70e825e46c66430.tar.gz |
Merge branch 'debug' into 'main'
fix progress reporting
Closes #101
See merge request larswirzenius/obnam!132
-rw-r--r-- | src/cmd/backup.rs | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/cmd/backup.rs b/src/cmd/backup.rs index 547775c..e6781e9 100644 --- a/src/cmd/backup.rs +++ b/src/cmd/backup.rs @@ -7,6 +7,7 @@ use crate::fsiter::FsIterator; use crate::generation::NascentGeneration; use bytesize::MIB; use log::info; +use std::path::Path; use std::time::SystemTime; use tempfile::NamedTempFile; @@ -49,13 +50,11 @@ fn initial_backup( config: &ClientConfig, client: &BackupClient, ) -> Result<(ChunkId, i64, Vec<BackupError>), ObnamError> { - let run = InitialBackup::new(config, &client)?; + info!("fresh backup without a previous generation"); let newtemp = NamedTempFile::new()?; + let run = InitialBackup::new(config, &client)?; let mut all_warnings = vec![]; let count = { - println!("create nascent"); - info!("fresh backup without a previous generation"); - let mut new = NascentGeneration::create(newtemp.path())?; for root in &config.roots { let iter = FsIterator::new(root); @@ -68,10 +67,7 @@ fn initial_backup( }; run.drop(); - let progress = BackupProgress::upload_generation(); - let gen_id = client.upload_generation(newtemp.path(), SQLITE_CHUNK_SIZE)?; - progress.finish(); - + let gen_id = upload_nascent_generation(client, newtemp.path())?; Ok((gen_id, count, all_warnings)) } @@ -80,13 +76,12 @@ fn incremental_backup( config: &ClientConfig, client: &BackupClient, ) -> Result<(ChunkId, i64, Vec<BackupError>), ObnamError> { - let mut run = IncrementalBackup::new(config, &client)?; + info!("incremental backup based on {}", old_ref); let newtemp = NamedTempFile::new()?; + let mut run = IncrementalBackup::new(config, &client)?; let mut all_warnings = vec![]; let count = { - info!("incremental backup based on {}", old_ref); let oldtemp = NamedTempFile::new()?; - let old = run.fetch_previous_generation(old_ref, oldtemp.path())?; run.start_backup(&old)?; let mut new = NascentGeneration::create(newtemp.path())?; @@ -99,10 +94,18 @@ fn incremental_backup( } new.file_count() }; + run.drop(); + + let gen_id = upload_nascent_generation(client, newtemp.path())?; + Ok((gen_id, count, all_warnings)) +} +fn upload_nascent_generation( + client: &BackupClient, + filename: &Path, +) -> Result<ChunkId, ObnamError> { let progress = BackupProgress::upload_generation(); - let gen_id = client.upload_generation(newtemp.path(), SQLITE_CHUNK_SIZE)?; + let gen_id = client.upload_generation(filename, SQLITE_CHUNK_SIZE)?; progress.finish(); - - Ok((gen_id, count, all_warnings)) + Ok(gen_id) } |