Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/dist/component/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ fn unpack_without_first_dir<R: Read>(archive: &mut tar::Archive<R>, path: &Path)
let entries = archive
.entries()
.chain_err(|| ErrorKind::ExtractingPackage)?;
let mut checked_parents: HashSet<PathBuf> = HashSet::new();
for entry in entries {
let mut entry = entry.chain_err(|| ErrorKind::ExtractingPackage)?;
let relpath = {
Expand All @@ -228,8 +229,21 @@ fn unpack_without_first_dir<R: Read>(archive: &mut tar::Archive<R>, path: &Path)

// Create the full path to the entry if it does not exist already
match full_path.parent() {
Some(parent) if !parent.exists() => {
::std::fs::create_dir_all(&parent).chain_err(|| ErrorKind::ExtractingPackage)?
Some(parent) => {
if !checked_parents.contains(parent) {
checked_parents.insert(parent.clone().to_owned());
// It would be nice to optimise this stat out, but the tar could be like so:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One moderately neat way to do that would be to re-use the components iterator from above, joining and checking as you go; but this is sufficient for now

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would result in stating every element from the top down, which is more than stating from the bottom up.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Or I misunderstood :). Thanks for merging it!)

// a/deep/file.txt
// a/file.txt
// which would require tracking the segments rather than a simple hash.
// Until profile shows that one stat per dir is a problem (vs one stat per file)
// leave till later.

if !parent.exists() {
::std::fs::create_dir_all(&parent)
.chain_err(|| ErrorKind::ExtractingPackage)?
}
}
}
_ => (),
};
Expand Down