pxar: avoid including archive root's exclude patterns in .pxarexclude-cli

The patterns from the archive root's .pxarexclude file are already present in
self.patterns when encode_pxarexclude_cli is called. Pass along the number of
CLI patterns and slice accordingly.

Suggested-By: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Fabian Ebner 2020-11-12 12:38:06 +01:00 committed by Wolfgang Bumiller
parent fb01fd3af6
commit c9097ff801

View File

@ -255,7 +255,7 @@ impl<'a, 'b> Archiver<'a, 'b> {
let file_name = file_entry.name.to_bytes(); let file_name = file_entry.name.to_bytes();
if is_root && file_name == b".pxarexclude-cli" { if is_root && file_name == b".pxarexclude-cli" {
self.encode_pxarexclude_cli(encoder, &file_entry.name)?; self.encode_pxarexclude_cli(encoder, &file_entry.name, old_patterns_count)?;
continue; continue;
} }
@ -387,8 +387,9 @@ impl<'a, 'b> Archiver<'a, 'b> {
&mut self, &mut self,
encoder: &mut Encoder, encoder: &mut Encoder,
file_name: &CStr, file_name: &CStr,
patterns_count: usize,
) -> Result<(), Error> { ) -> Result<(), Error> {
let content = generate_pxar_excludes_cli(&self.patterns); let content = generate_pxar_excludes_cli(&self.patterns[..patterns_count]);
if let Some(ref mut catalog) = self.catalog { if let Some(ref mut catalog) = self.catalog {
catalog.add_file(file_name, content.len() as u64, 0)?; catalog.add_file(file_name, content.len() as u64, 0)?;