client: pxar: encode prelude based on writer variant

Currently, whether to encode the exlcude patterns passed via cli as
prelude or via the `.pxar-exclude-cli` is based on the presence of
a previous metadata accessor.
That leaves however to the encoding of the file entry instead of the
prelude for split archives in `data` mode and for the first snapshot
in a backup, creating undesired padding in the first payload chunk.

Therefore, use the pxar writer variant to make the decision instead.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
This commit is contained in:
Christian Ebner 2024-06-10 13:06:21 +02:00 committed by Fabian Grünbichler
parent 903ab2e938
commit afdc0f0e42

View File

@ -183,6 +183,7 @@ struct Archiver {
previous_payload_index: Option<DynamicIndexReader>, previous_payload_index: Option<DynamicIndexReader>,
cache: PxarLookaheadCache, cache: PxarLookaheadCache,
reuse_stats: ReuseStats, reuse_stats: ReuseStats,
split_archive: bool,
} }
type Encoder<'a, T> = pxar::encoder::aio::Encoder<'a, T>; type Encoder<'a, T> = pxar::encoder::aio::Encoder<'a, T>;
@ -247,7 +248,8 @@ where
)?); )?);
} }
let prelude = if options.previous_ref.is_some() && !patterns.is_empty() { let split_archive = writers.archive.payload().is_some();
let prelude = if split_archive && !patterns.is_empty() {
let prelude = PbsClientPrelude { let prelude = PbsClientPrelude {
exclude_patterns: Some(String::from_utf8(generate_pxar_excludes_cli( exclude_patterns: Some(String::from_utf8(generate_pxar_excludes_cli(
&patterns[..], &patterns[..],
@ -258,7 +260,7 @@ where
None None
}; };
let metadata_mode = options.previous_ref.is_some() && writers.archive.payload().is_some(); let metadata_mode = options.previous_ref.is_some() && split_archive;
let (previous_payload_index, previous_metadata_accessor) = let (previous_payload_index, previous_metadata_accessor) =
if let Some(refs) = options.previous_ref { if let Some(refs) = options.previous_ref {
( (
@ -291,6 +293,7 @@ where
previous_payload_index, previous_payload_index,
cache: PxarLookaheadCache::new(options.max_cache_size), cache: PxarLookaheadCache::new(options.max_cache_size),
reuse_stats: ReuseStats::default(), reuse_stats: ReuseStats::default(),
split_archive,
}; };
archiver archiver
@ -388,12 +391,11 @@ impl Archiver {
for file_entry in file_list { for file_entry in file_list {
let file_name = file_entry.name.to_bytes(); let file_name = file_entry.name.to_bytes();
if is_root if is_root && file_name == b".pxarexclude-cli" {
&& file_name == b".pxarexclude-cli" if !self.split_archive {
&& previous_metadata_accessor.is_none() self.encode_pxarexclude_cli(encoder, &file_entry.name, old_patterns_count)
{ .await?;
self.encode_pxarexclude_cli(encoder, &file_entry.name, old_patterns_count) }
.await?;
continue; continue;
} }
@ -1944,6 +1946,7 @@ mod tests {
suggested_boundaries: Some(suggested_boundaries), suggested_boundaries: Some(suggested_boundaries),
cache: PxarLookaheadCache::new(None), cache: PxarLookaheadCache::new(None),
reuse_stats: ReuseStats::default(), reuse_stats: ReuseStats::default(),
split_archive: true,
}; };
let accessor = Accessor::new(pxar::PxarVariant::Unified(reader), metadata_size) let accessor = Accessor::new(pxar::PxarVariant::Unified(reader), metadata_size)