pxar: fix anchored exclusion at archive root

There is no leading slash in an entry's full_path, causing an anchored
exclude at the root level to fail, e.g. having "/name" as the content of the
file archive/root/.pxarexclude didn't match the file archive/root/name

Fix this by prepending a leading slash before matching.

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 10:03:50 +01:00 committed by Wolfgang Bumiller
parent b649887e9a
commit 874bd5454d
1 changed files with 2 additions and 1 deletions

View File

@ -443,9 +443,10 @@ impl<'a, 'b> Archiver<'a, 'b> {
Err(err) => bail!("stat failed on {:?}: {}", full_path, err), Err(err) => bail!("stat failed on {:?}: {}", full_path, err),
}; };
let match_path = PathBuf::from("/").join(full_path.clone());
if self if self
.patterns .patterns
.matches(full_path.as_os_str().as_bytes(), Some(stat.st_mode as u32)) .matches(match_path.as_os_str().as_bytes(), Some(stat.st_mode as u32))
== Some(MatchType::Exclude) == Some(MatchType::Exclude)
{ {
continue; continue;