public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH proxmox-backup] client: pxar: let backup stream callers see each archived entry
@ 2026-11-30 10:03 Dietmar Maurer
  2026-12-01  2:27 ` applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Dietmar Maurer @ 2026-11-30 10:03 UTC (permalink / raw)
  To: pbs-devel

A graphical client wants to show which file a running backup is at.
Byte counts alone can mislead: a sparse file, such as a core dump,
can be read for a long time while the counter climbs far beyond the
data size on disk.

The archiver already calls a per-entry callback, but the stream
hardwired it to a debug log line. Callers can now pass their own
callback, which runs in addition to the log line. The command line
client passes none, so its behavior is unchanged.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
---
 pbs-client/src/pxar_backup_stream.rs | 17 ++++++++++++++++-
 proxmox-backup-client/src/main.rs    |  1 +
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/pbs-client/src/pxar_backup_stream.rs b/pbs-client/src/pxar_backup_stream.rs
index 430eee01f..ed179bddf 100644
--- a/pbs-client/src/pxar_backup_stream.rs
+++ b/pbs-client/src/pxar_backup_stream.rs
@@ -22,6 +22,9 @@ use pbs_datastore::catalog::{BackupCatalogWriter, CatalogWriter};
 use crate::inject_reused_chunks::InjectChunks;
 use crate::pxar::create::PxarWriters;
 
+/// Called with the archive-relative path of each entry before it is encoded.
+pub type PxarEntryCallback = Box<dyn FnMut(&Path) + Send>;
+
 /// Stream implementation to encode and upload .pxar archives.
 ///
 /// The hyper client needs an async Stream for file upload, so we
@@ -50,6 +53,7 @@ impl PxarBackupStream {
         options: crate::pxar::PxarCreateOptions,
         boundaries: Option<mpsc::Sender<InjectChunks>>,
         separate_payload_stream: bool,
+        mut on_entry: Option<PxarEntryCallback>,
     ) -> Result<(Self, Option<Self>), Error> {
         let buffer_size = 256 * 1024;
 
@@ -97,6 +101,9 @@ impl PxarBackupStream {
                 crate::pxar::Flags::DEFAULT,
                 move |path| {
                     debug!("{:?}", path);
+                    if let Some(on_entry) = on_entry.as_mut() {
+                        on_entry(path);
+                    }
                     Ok(())
                 },
                 options,
@@ -145,10 +152,18 @@ impl PxarBackupStream {
         options: crate::pxar::PxarCreateOptions,
         boundaries: Option<mpsc::Sender<InjectChunks>>,
         separate_payload_stream: bool,
+        on_entry: Option<PxarEntryCallback>,
     ) -> Result<(Self, Option<Self>), Error> {
         let dir = nix::dir::Dir::open(dirname, OFlag::O_DIRECTORY, Mode::empty())?;
 
-        Self::new(dir, catalog, options, boundaries, separate_payload_stream)
+        Self::new(
+            dir,
+            catalog,
+            options,
+            boundaries,
+            separate_payload_stream,
+            on_entry,
+        )
     }
 }
 
diff --git a/proxmox-backup-client/src/main.rs b/proxmox-backup-client/src/main.rs
index 5238a75ea..156e457de 100644
--- a/proxmox-backup-client/src/main.rs
+++ b/proxmox-backup-client/src/main.rs
@@ -281,6 +281,7 @@ async fn backup_directory<P: AsRef<Path>>(
         pxar_create_options,
         Some(payload_boundaries_tx),
         payload_target.is_some(),
+        None,
     )?;
 
     let mut chunk_stream = ChunkStream::new(pxar_stream, chunk_size, None, None);
-- 
2.47.3




^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-01  2:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 10:03 [PATCH proxmox-backup] client: pxar: let backup stream callers see each archived entry Dietmar Maurer
2026-12-01  2:27 ` applied: " Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal