src/pxar/sequential_decoder.rs: remove old comments and refactoring

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
This commit is contained in:
Christian Ebner 2019-07-16 13:19:50 +02:00 committed by Dietmar Maurer
parent 9f8fcdd050
commit 0b39674895

View File

@ -555,7 +555,6 @@ impl <'a, R: Read, F: Fn(&Path) -> Result<(), Error>> SequentialDecoder<'a, R, F
bail!("detected short payload"); bail!("detected short payload");
} }
let need = (head.size - HEADER_SIZE) as usize; let need = (head.size - HEADER_SIZE) as usize;
//self.reader.seek(SeekFrom::Current(need as i64))?;
let mut done = 0; let mut done = 0;
while done < need { while done < need {
@ -645,25 +644,14 @@ impl <'a, R: Read, F: Fn(&Path) -> Result<(), Error>> SequentialDecoder<'a, R, F
if head.htype == PXAR_FORMAT_HARDLINK { if head.htype == PXAR_FORMAT_HARDLINK {
let (target, _offset) = self.read_hardlink(head.size)?; let (target, _offset) = self.read_hardlink(head.size)?;
let target_path = base_path.join(&target); let target_path = base_path.join(&target);
//println!("HARDLINK: {} {:?} -> {:?}", offset, full_path, target_path);
hardlink(&target_path, &full_path)?; hardlink(&target_path, &full_path)?;
return Ok(()); return Ok(());
} }
check_ca_header::<CaFormatEntry>(&head, CA_FORMAT_ENTRY)?; check_ca_header::<CaFormatEntry>(&head, CA_FORMAT_ENTRY)?;
let entry: CaFormatEntry = self.read_item()?; let entry: CaFormatEntry = self.read_item()?;
match entry.mode as u32 & libc::S_IFMT {
let mode = entry.mode as u32; //fixme: upper 32bits? libc::S_IFDIR => self.restore_dir_sequential(base_path, relative_path, &full_path, parent_fd, &entry, &filename),
let ifmt = mode & libc::S_IFMT;
if ifmt == libc::S_IFDIR {
return self.restore_dir_sequential(base_path, relative_path, &full_path, parent_fd, &entry, &filename);
}
if filename.is_empty() {
bail!("got empty file name at {:?}", full_path);
}
match ifmt {
libc::S_IFLNK => self.restore_symlink(parent_fd, &full_path, &entry, &filename), libc::S_IFLNK => self.restore_symlink(parent_fd, &full_path, &entry, &filename),
libc::S_IFSOCK => self.restore_socket(parent_fd, &entry, &filename), libc::S_IFSOCK => self.restore_socket(parent_fd, &entry, &filename),
libc::S_IFIFO => self.restore_fifo(parent_fd, &entry, &filename), libc::S_IFIFO => self.restore_fifo(parent_fd, &entry, &filename),