diff options
Diffstat (limited to 'src/filestore/staging.rs')
-rw-r--r-- | src/filestore/staging.rs | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/filestore/staging.rs b/src/filestore/staging.rs index 73701cd..9f60d32 100644 --- a/src/filestore/staging.rs +++ b/src/filestore/staging.rs @@ -17,6 +17,9 @@ use anyhow::anyhow; use futures::stream::Stream; use indicatif::ProgressBar; use log::trace; +use resiter::AndThen; +use resiter::Filter; +use resiter::Map; use result_inspect::ResultInspect; use crate::filestore::path::ArtifactPath; @@ -54,15 +57,25 @@ impl StagingStore { .and_then(|bytes| { let mut archive = tar::Archive::new(&bytes[..]); - let outputs = archive - .entries() - .context("Fetching entries from tar archive")? - .map(|ent| { - let p = ent? + let outputs = archive.entries()? + .map_err(Error::from) + .filter_ok(|entry| entry.header().entry_type() == tar::EntryType::Regular) + .and_then_ok(|entry| { + let entry = entry .path() - .context("Getting path of TAR entry")? - .into_owned(); - Ok(p) + .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::<std::path::PathBuf>(); + + Ok(entry) }) .inspect(|p| trace!("Path in tar archive: {:?}", p)) .collect::<Result<Vec<_>>>() |