src/pxar/decoder.rs: fix wrong filename check for Decoder::restore()
As it turns out the original implementation was correct and the start in `DirectoryEntry` points to the `PxarEntry` and not as wrongly stated to the filename. This reverts the incorrect code and adds comments to the fields clarifying this. Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
This commit is contained in:
parent
33ad183a40
commit
fb2554de29
@ -17,7 +17,9 @@ use super::match_pattern::MatchPattern;
|
||||
use proxmox::tools::io::ReadExt;
|
||||
|
||||
pub struct DirectoryEntry {
|
||||
/// Points to the `PxarEntry` of the directory
|
||||
start: u64,
|
||||
/// Points past the goodbye table tail
|
||||
end: u64,
|
||||
pub filename: OsString,
|
||||
pub entry: PxarEntry,
|
||||
@ -73,16 +75,6 @@ impl<R: Read + Seek, F: Fn(&Path) -> Result<(), Error>> Decoder<R, F> {
|
||||
pub fn restore(&mut self, dir: &DirectoryEntry, path: &Path, pattern: &Vec<MatchPattern>) -> Result<(), Error> {
|
||||
let start = dir.start;
|
||||
self.seek(SeekFrom::Start(start))?;
|
||||
// Except for the root dir, `DirectoryEntry` start points to the filename.
|
||||
// But `SequentialDecoder::restore()` expects the entry point to be of
|
||||
// type `PxarEntry`, so lets skip over the filename here if present.
|
||||
if start != 0 {
|
||||
let header: PxarHeader = self.inner.read_item()?;
|
||||
if header.htype != PXAR_FILENAME {
|
||||
bail!("Expected PXAR_FILENAME, encountered 0x{:x?}", header.htype);
|
||||
}
|
||||
let _filename = self.inner.read_filename(header.size)?;
|
||||
}
|
||||
self.inner.restore(path, pattern)?;
|
||||
|
||||
Ok(())
|
||||
|
Loading…
Reference in New Issue
Block a user