Skip to content

Commit ab40997

Browse files
committed
Create full path to file entries
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.
1 parent 49c6fe2 commit ab40997

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/rustup-dist/src/component/package.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,14 @@ fn unpack_without_first_dir<R: Read>(archive: &mut tar::Archive<R>, path: &Path)
199199
// Throw away the first path component
200200
components.next();
201201
let full_path = path.join(&components.as_path());
202+
203+
// Create the full path to the entry if it does not exist already
204+
match full_path.parent() {
205+
Some(parent) if !parent.exists() =>
206+
try!(::std::fs::create_dir_all(&parent).chain_err(|| ErrorKind::ExtractingPackage)),
207+
_ => (),
208+
};
209+
202210
try!(entry.unpack(&full_path).chain_err(|| ErrorKind::ExtractingPackage));
203211
}
204212

0 commit comments

Comments
 (0)