diff options
author | Lars Wirzenius <liw@liw.fi> | 2022-03-22 17:10:02 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2022-03-22 17:10:02 +0000 |
commit | 4a9b26903d48d622f7f2a01eb54eec88e92da868 (patch) | |
tree | 6d1a5f4fa835cd217d256ac3cdd5baec5902a2af /src/backup_run.rs | |
parent | 7ae1f33ad0cd0df227e83997268ce2f3540db8d7 (diff) | |
parent | 018fcd28c8dbf84d34cc370496139f678664ca8f (diff) | |
download | obnam2-4a9b26903d48d622f7f2a01eb54eec88e92da868.tar.gz |
Merge branch 'liw/schema-refactor' into 'main'
add backup database schema to evolove; break server database
Closes #194 and #192
See merge request obnam/obnam!222
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) => { |