pxar: fix relative '!' rules in .pxarexclude

and reduce indentation

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2020-10-15 12:17:55 +02:00
parent 2081327428
commit 32a4695c46
1 changed files with 46 additions and 43 deletions

View File

@ -291,13 +291,15 @@ impl<'a, 'b> Archiver<'a, 'b> {
}
fn read_pxar_excludes(&mut self, parent: RawFd) -> Result<(), Error> {
let fd = self.open_file(parent, c_str!(".pxarexclude"), OFlag::O_RDONLY, false)?;
let fd = match self.open_file(parent, c_str!(".pxarexclude"), OFlag::O_RDONLY, false)? {
Some(fd) => fd,
None => return Ok(()),
};
let old_pattern_count = self.patterns.len();
let path_bytes = self.path.as_os_str().as_bytes();
if let Some(fd) = fd {
let file = unsafe { std::fs::File::from_raw_fd(fd.into_raw_fd()) };
use io::BufRead;
@ -334,6 +336,8 @@ impl<'a, 'b> Archiver<'a, 'b> {
buf.extend(path_bytes);
buf.extend(&line[1..]); // without the '!'
(&buf[..], MatchType::Include)
} else if line.starts_with(b"!") {
(&line[1..], MatchType::Include)
} else {
(line, MatchType::Exclude)
};
@ -345,7 +349,6 @@ impl<'a, 'b> Archiver<'a, 'b> {
}
}
}
}
Ok(())
}