diff options
author | Lars Wirzenius <liw@liw.fi> | 2022-03-20 07:52:38 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2022-03-20 10:53:46 +0200 |
commit | a2bee6568dee4c23ed008e657f38352da4190f24 (patch) | |
tree | 7fb2550a80b71692395155b8c4c4dc7c31f27c77 /src/backup_run.rs | |
parent | 873738f0e1dc01f2a75e5e60ae68094b4558ed07 (diff) | |
download | obnam2-a2bee6568dee4c23ed008e657f38352da4190f24.tar.gz |
feat: allow user to choose backup schema version for new backups
The way this is currently implemented resulted in a lot of code
duplication in src/generation.rs. This should be refactored later. My
first attempt to do it by adding a trait for a schema variant failed.
Sponsored-by: author
Diffstat (limited to 'src/backup_run.rs')
-rw-r--r-- | src/backup_run.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/backup_run.rs b/src/backup_run.rs index 9454625..b03a7ee 100644 --- a/src/backup_run.rs +++ b/src/backup_run.rs @@ -8,7 +8,7 @@ use crate::chunkid::ChunkId; use crate::client::{BackupClient, ClientError}; use crate::config::ClientConfig; use crate::db::DatabaseError; -use crate::dbgen::FileId; +use crate::dbgen::{schema_version, FileId, DEFAULT_SCHEMA_MAJOR}; use crate::error::ObnamError; use crate::fsentry::{FilesystemEntry, FilesystemKind}; use crate::fsiter::{AnnotatedFsEntry, FsIterError, FsIterator}; @@ -16,6 +16,7 @@ use crate::generation::{ GenId, LocalGeneration, LocalGenerationError, NascentError, NascentGeneration, }; use crate::policy::BackupPolicy; +use crate::schema::SchemaVersion; use bytesize::MIB; use chrono::{DateTime, Local}; @@ -132,7 +133,8 @@ impl<'a> BackupRun<'a> { match genid { None => { // Create a new, empty generation. - NascentGeneration::create(oldname)?.close()?; + let schema = schema_version(DEFAULT_SCHEMA_MAJOR).unwrap(); + NascentGeneration::create(oldname, schema)?.close()?; // Open the newly created empty generation. Ok(LocalGeneration::open(oldname)?) @@ -173,11 +175,12 @@ impl<'a> BackupRun<'a> { config: &ClientConfig, old: &LocalGeneration, newpath: &Path, + schema: SchemaVersion, ) -> Result<RootsBackupOutcome, ObnamError> { let mut warnings: Vec<BackupError> = vec![]; let mut new_cachedir_tags = vec![]; let files_count = { - let mut new = NascentGeneration::create(newpath)?; + let mut new = NascentGeneration::create(newpath, schema)?; for root in &config.roots { match self.backup_one_root(config, old, &mut new, root).await { Ok(mut o) => { |