Skip to content

Commit

Permalink
Create full path to file entries
Browse files Browse the repository at this point in the history
The `unpack` function assumes that the directory in which the file is
being extracted exists, while most `tar` tools will automatically
create the intermediate directories if they are missing.

This would have avoided #1092.
  • Loading branch information
ranma42 committed May 9, 2017
1 parent 49c6fe2 commit bd64be4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/rustup-dist/src/component/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,14 @@ fn unpack_without_first_dir<R: Read>(archive: &mut tar::Archive<R>, path: &Path)
// Throw away the first path component
components.next();
let full_path = path.join(&components.as_path());

// Create the full path to the entry if it does not exist already
match full_path.parent() {
Some(parent) if !parent.exists() =>
try!(::std::fs::create_dir_all(&parent).chain_err(|| ErrorKind::ExtractingPackage)),
_ => (),
};

try!(entry.unpack(&full_path).chain_err(|| ErrorKind::ExtractingPackage));
}

Expand Down

0 comments on commit bd64be4

Please sign in to comment.