From 48139725676fcce89a70897546969623f2474693 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Mon, 21 Mar 2022 09:12:49 +0200 Subject: feat! store list of generations in a "client trust root" chunk Backups made with this version can't be restored with old clients, and vice version. Sponsored-by: author --- src/cmd/backup.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/cmd/backup.rs') diff --git a/src/cmd/backup.rs b/src/cmd/backup.rs index 6983de4..db65da0 100644 --- a/src/cmd/backup.rs +++ b/src/cmd/backup.rs @@ -1,6 +1,7 @@ //! The `backup` subcommand. -use crate::backup_run::BackupRun; +use crate::backup_run::{current_timestamp, BackupRun}; +use crate::chunk::ClientTrust; use crate::client::BackupClient; use crate::config::ClientConfig; use crate::dbgen::{schema_version, FileId, DEFAULT_SCHEMA_MAJOR}; @@ -37,7 +38,12 @@ impl Backup { eprintln!("backup: schema: {}", schema); let client = BackupClient::new(config)?; - let genlist = client.list_generations().await?; + let trust = client + .get_client_trust() + .await? + .or_else(|| Some(ClientTrust::new("FIXME", None, current_timestamp(), vec![]))) + .unwrap(); + let genlist = client.list_generations(&trust); let temp = tempdir()?; let oldtemp = temp.path().join("old.db"); @@ -64,6 +70,13 @@ impl Backup { } }; + let mut trust = trust; + trust.append_backup(outcome.gen_id.as_chunk_id()); + trust.finalize(current_timestamp()); + let trust = trust.to_data_chunk()?; + let trust_id = client.upload_chunk(trust).await?; + info!("uploaded new client-trust {}", trust_id); + for w in outcome.warnings.iter() { println!("warning: {}", w); } -- cgit v1.2.1