pxar: implement allow_existing_dirs for pxar decoder

By default, restoring an archive will fail if files with the same filename
already exist in the target directory.

By setting the allow_existing_dirs flag, the restore will not fail if an
existing directory is encountered.
The metadata (permissions, acls, ...) of the existing directory will be set
to the ones from the archive.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
This commit is contained in:
Christian Ebner
2019-07-29 14:01:45 +02:00
committed by Dietmar Maurer
parent 46d5aa0a09
commit 6a87910949
3 changed files with 15 additions and 7 deletions

View File

@ -739,10 +739,6 @@ fn restore(
if let Some(target) = target {
if allow_existing_dirs {
unimplemented!();
}
let feature_flags = pxar::CA_FORMAT_DEFAULT;
let mut decoder = pxar::SequentialDecoder::new(&mut reader, feature_flags, |path| {
if verbose {
@ -750,6 +746,8 @@ fn restore(
}
Ok(())
});
decoder.set_allow_existing_dirs(allow_existing_dirs);
decoder.restore(Path::new(target), &Vec::new())?;
} else {