summaryrefslogtreecommitdiffstats
path: root/src/filestore/path.rs
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-04-12 18:43:04 +0200
committerMatthias Beyer <matthias.beyer@atos.net>2021-04-12 19:34:36 +0200
commit3537f8e1d174f2ce422c9024a9e0d6df87ad9207 (patch)
treec400711ba25cbf376c09795c0d503ef82fc7f9b4 /src/filestore/path.rs
parentb167c4a13f467ea271351b51b2d331f4fb96f95d (diff)
Filter out the /outputs/ directory
The issue here is that we copy all build results (packages) in the container to /outputs and then butido uses that directory to fetch the outputs of the build. But, because how the docker API works, we get a TAR stream from docker that _contains_ the /outputs directory. But of course, we don't want that. Until now, that was no issue. But it has become one now that we start adopting butido for our real-world scenarios. This patch adds filtering out that /outputs portion of the pathes from the tar archive when writing all the things to disc. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net> Tested-by: Matthias Beyer <matthias.beyer@atos.net>
Diffstat (limited to 'src/filestore/path.rs')
-rw-r--r--src/filestore/path.rs30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/filestore/path.rs b/src/filestore/path.rs
index e8c7a26..3d74992 100644
--- a/src/filestore/path.rs
+++ b/src/filestore/path.rs
@@ -92,7 +92,35 @@ impl StoreRoot {
where
R: std::io::Read,
{
- ar.unpack(&self.0).map_err(Error::from)
+ ar.entries()?
+ .into_iter()
+ .map_err(Error::from)
+ .filter_ok(|entry| entry.header().entry_type() == tar::EntryType::Regular)
+ .and_then_ok(|mut entry| -> Result<_> {
+ let path = entry
+ .path()
+ .context("Getting path from entry in Archive")?
+ .components()
+ .filter(|comp| {
+ log::trace!("Filtering path component: '{:?}'", comp);
+ let osstr = std::ffi::OsStr::new(crate::consts::OUTPUTS_DIR_NAME);
+ match comp {
+ std::path::Component::Normal(s) => *s != osstr,
+ _ => true,
+ }
+ })
+ .collect::<PathBuf>();
+
+ log::trace!("Path = '{:?}'", path);
+ let unpack_dest = self.0.join(path);
+ log::trace!("Unpack to = '{:?}'", unpack_dest);
+
+ entry.unpack(unpack_dest)
+ .map(|_| ())
+ .map_err(Error::from)
+ })
+ .collect::<Result<Vec<_>>>()
+ .map(|_| ())
}
}