From a5951b4f38b5a315a1306ec7b080b9b244c4fc2d Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 7 Jul 2021 11:34:45 +0200 Subject: [PATCH] move manifest and backup_info to pbs-datastore Signed-off-by: Wolfgang Bumiller --- pbs-datastore/Cargo.toml | 1 + pbs-datastore/src/backup_info.rs | 4 ++-- pbs-datastore/src/lib.rs | 7 ++++++- pbs-datastore/src/manifest.rs | 11 ++++++----- src/backup/mod.rs | 11 ++++------- src/tools/mod.rs | 2 +- 6 files changed, 20 insertions(+), 16 deletions(-) diff --git a/pbs-datastore/Cargo.toml b/pbs-datastore/Cargo.toml index e66a9bb9..2f2f9d39 100644 --- a/pbs-datastore/Cargo.toml +++ b/pbs-datastore/Cargo.toml @@ -9,6 +9,7 @@ description = "low level pbs data storage access" anyhow = "1.0" crc32fast = "1" endian_trait = { version = "0.6", features = [ "arrays" ] } +libc = "0.2" log = "0.4" nix = "0.19.1" openssl = "0.10" diff --git a/pbs-datastore/src/backup_info.rs b/pbs-datastore/src/backup_info.rs index 34bf26a3..f77098ee 100644 --- a/pbs-datastore/src/backup_info.rs +++ b/pbs-datastore/src/backup_info.rs @@ -3,7 +3,7 @@ use std::path::{Path, PathBuf}; use anyhow::{bail, format_err, Error}; -use crate::api2::types::{ +use pbs_api_types::{ BACKUP_ID_REGEX, BACKUP_TYPE_REGEX, BACKUP_DATE_REGEX, @@ -372,7 +372,7 @@ impl BackupInfo { // backup is considered unfinished if there is no manifest self.files .iter() - .any(|name| name == super::MANIFEST_BLOB_NAME) + .any(|name| name == MANIFEST_BLOB_NAME) } } diff --git a/pbs-datastore/src/lib.rs b/pbs-datastore/src/lib.rs index 09ba0103..25ec669c 100644 --- a/pbs-datastore/src/lib.rs +++ b/pbs-datastore/src/lib.rs @@ -178,6 +178,7 @@ pub fn backup_group() -> Result { .ok_or_else(|| format_err!("Unable to lookup backup user.")) } +pub mod backup_info; pub mod catalog; pub mod checksum_reader; pub mod checksum_writer; @@ -191,15 +192,19 @@ pub mod data_blob_writer; pub mod file_formats; pub mod index; pub mod key_derivation; +pub mod manifest; pub mod task; +pub use backup_info::{BackupDir, BackupGroup, BackupInfo}; pub use checksum_reader::ChecksumReader; pub use checksum_writer::ChecksumWriter; pub use chunker::Chunker; -pub use crypt_config::{CryptConfig, CryptMode}; +pub use crypt_config::{CryptConfig, CryptMode, Fingerprint}; pub use crypt_reader::CryptReader; pub use crypt_writer::CryptWriter; +pub use data_blob::DataBlob; pub use key_derivation::{ decrypt_key, load_and_decrypt_key, rsa_decrypt_key_config, rsa_encrypt_key_config, }; pub use key_derivation::{Kdf, KeyConfig, KeyDerivationConfig, KeyInfo}; +pub use manifest::BackupManifest; diff --git a/pbs-datastore/src/manifest.rs b/pbs-datastore/src/manifest.rs index 47f9cadc..4c6d5137 100644 --- a/pbs-datastore/src/manifest.rs +++ b/pbs-datastore/src/manifest.rs @@ -1,11 +1,12 @@ -use anyhow::{bail, format_err, Error}; use std::convert::TryFrom; use std::path::Path; -use serde_json::{json, Value}; -use ::serde::{Deserialize, Serialize}; +use anyhow::{bail, format_err, Error}; -use crate::backup::{BackupDir, CryptMode, CryptConfig, Fingerprint}; +use serde_json::{json, Value}; +use serde::{Deserialize, Serialize}; + +use crate::{BackupDir, CryptMode, CryptConfig, Fingerprint}; pub const MANIFEST_BLOB_NAME: &str = "index.json.blob"; pub const MANIFEST_LOCK_NAME: &str = ".index.json.lck"; @@ -149,7 +150,7 @@ impl BackupManifest { // Generate canonical json fn to_canonical_json(value: &Value) -> Result, Error> { - crate::tools::json::to_canonical_json(value) + pbs_tools::json::to_canonical_json(value) } /// Compute manifest signature diff --git a/src/backup/mod.rs b/src/backup/mod.rs index dcfb4bd4..c0acc246 100644 --- a/src/backup/mod.rs +++ b/src/backup/mod.rs @@ -178,6 +178,8 @@ pub fn backup_group() -> Result { } } +pub use pbs_datastore::backup_info; +pub use pbs_datastore::backup_info::*; pub use pbs_datastore::catalog; pub use pbs_datastore::catalog::*; pub use pbs_datastore::checksum_reader; @@ -204,9 +206,8 @@ pub use pbs_datastore::index; pub use pbs_datastore::index::*; pub use pbs_datastore::key_derivation; pub use pbs_datastore::key_derivation::*; - -mod manifest; -pub use manifest::*; +pub use pbs_datastore::manifest; +pub use pbs_datastore::manifest::*; mod chunk_stream; pub use chunk_stream::*; @@ -226,10 +227,6 @@ pub use fixed_index::*; mod dynamic_index; pub use dynamic_index::*; -#[macro_use] -mod backup_info; -pub use backup_info::*; - mod prune; pub use prune::*; diff --git a/src/tools/mod.rs b/src/tools/mod.rs index 1e1ea878..1e26bdc3 100644 --- a/src/tools/mod.rs +++ b/src/tools/mod.rs @@ -23,6 +23,7 @@ use proxmox_http::{ ProxyConfig, }; +pub use pbs_tools::json; pub use pbs_tools::nom; pub use pbs_tools::{run_command, command_output, command_output_as_string}; @@ -40,7 +41,6 @@ pub mod fuse_loop; mod memcom; pub use memcom::Memcom; -pub mod json; pub mod logrotate; pub mod loopdev; pub mod lru_cache;