[pbs-devel] [PATCH v5 proxmox-backup 18/62] client: pxar: add optional pxar payload writer instance
Christian Ebner
c.ebner at proxmox.com
Tue May 7 17:52:00 CEST 2024
Extend the PxarWriters to hold the optional pxar payload writer
and attach it to the pxar encoder during archive creation.
The payload writer will encode the payloads of regular files to a
different backup stream, splitting the metadata from the payload
data.
Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
changes since version 4:
- no changes
pbs-client/src/pxar/create.rs | 20 ++++++++++++++++---
pbs-client/src/pxar_backup_stream.rs | 2 +-
.../src/proxmox_restore_daemon/api.rs | 10 ++++++++--
pxar-bin/src/main.rs | 2 +-
tests/catar.rs | 2 +-
5 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/pbs-client/src/pxar/create.rs b/pbs-client/src/pxar/create.rs
index 82f05889b..2bb5a6253 100644
--- a/pbs-client/src/pxar/create.rs
+++ b/pbs-client/src/pxar/create.rs
@@ -137,12 +137,21 @@ type Encoder<'a, T> = pxar::encoder::aio::Encoder<'a, T>;
pub struct PxarWriters<T> {
writer: T,
+ payload_writer: Option<T>,
catalog: Option<Arc<Mutex<dyn BackupCatalogWriter + Send>>>,
}
impl<T> PxarWriters<T> {
- pub fn new(writer: T, catalog: Option<Arc<Mutex<dyn BackupCatalogWriter + Send>>>) -> Self {
- Self { writer, catalog }
+ pub fn new(
+ writer: T,
+ payload_writer: Option<T>,
+ catalog: Option<Arc<Mutex<dyn BackupCatalogWriter + Send>>>,
+ ) -> Self {
+ Self {
+ writer,
+ payload_writer,
+ catalog,
+ }
}
}
@@ -180,7 +189,12 @@ where
set.insert(stat.st_dev);
}
- let mut encoder = Encoder::new(&mut writers.writer, &metadata, None).await?;
+ let mut encoder = Encoder::new(
+ &mut writers.writer,
+ &metadata,
+ writers.payload_writer.as_mut(),
+ )
+ .await?;
let mut patterns = options.patterns;
diff --git a/pbs-client/src/pxar_backup_stream.rs b/pbs-client/src/pxar_backup_stream.rs
index bfa108a8b..cdfb7eaa8 100644
--- a/pbs-client/src/pxar_backup_stream.rs
+++ b/pbs-client/src/pxar_backup_stream.rs
@@ -58,7 +58,7 @@ impl PxarBackupStream {
let writer = pxar::encoder::sync::StandardWriter::new(writer);
if let Err(err) = crate::pxar::create_archive(
dir,
- PxarWriters::new(writer, Some(catalog)),
+ PxarWriters::new(writer, None, Some(catalog)),
crate::pxar::Flags::DEFAULT,
move |path| {
log::debug!("{:?}", path);
diff --git a/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs b/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs
index 1ee200573..ea97976e6 100644
--- a/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs
+++ b/proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs
@@ -358,8 +358,14 @@ fn extract(
};
let pxar_writer = TokioWriter::new(writer);
- create_archive(dir, PxarWriters::new(pxar_writer, None), Flags::DEFAULT, |_| Ok(()), options)
- .await
+ create_archive(
+ dir,
+ PxarWriters::new(pxar_writer, None, None),
+ Flags::DEFAULT,
+ |_| Ok(()),
+ options,
+ )
+ .await
}
.await;
if let Err(err) = result {
diff --git a/pxar-bin/src/main.rs b/pxar-bin/src/main.rs
index ae2325078..34944cf16 100644
--- a/pxar-bin/src/main.rs
+++ b/pxar-bin/src/main.rs
@@ -377,7 +377,7 @@ async fn create_archive(
let writer = pxar::encoder::sync::StandardWriter::new(writer);
pbs_client::pxar::create_archive(
dir,
- PxarWriters::new(writer, None),
+ PxarWriters::new(writer, None, None),
feature_flags,
move |path| {
log::debug!("{:?}", path);
diff --git a/tests/catar.rs b/tests/catar.rs
index f414da8c9..9e96a8610 100644
--- a/tests/catar.rs
+++ b/tests/catar.rs
@@ -35,7 +35,7 @@ fn run_test(dir_name: &str) -> Result<(), Error> {
let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(create_archive(
dir,
- PxarWriters::new(writer, None),
+ PxarWriters::new(writer, None, None),
Flags::DEFAULT,
|_| Ok(()),
options,
--
2.39.2
More information about the pbs-devel
mailing list