Skip to content

Commit fd39bd1

Browse files
committed
auto merge of #9148 : jakub-/rust/rustpkg-install-mkdir-p, r=catamorphism
Testing this is a little tricky as an intermediate temporary directory is only used for remote git repositories and therefore that path cannot be reliably exercised in the tests.
2 parents 323e8f0 + 3d14e82 commit fd39bd1

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/librustpkg/package_source.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use context::*;
1818
use crate::Crate;
1919
use messages::*;
2020
use source_control::{git_clone, git_clone_general};
21-
use path_util::{find_dir_using_rust_path_hack, default_workspace};
21+
use path_util::{find_dir_using_rust_path_hack, default_workspace, make_dir_rwx_recursive};
2222
use util::compile_crate;
2323
use workspace::is_workspace;
2424
use workcache_support;
@@ -197,12 +197,14 @@ impl PkgSrc {
197197
url, clone_target.to_str(), pkgid.version.to_str());
198198

199199
if git_clone_general(url, &clone_target, &pkgid.version) {
200-
// since the operation succeeded, move clone_target to local
201-
if !os::rename_file(&clone_target, local) {
202-
None
200+
// Since the operation succeeded, move clone_target to local.
201+
// First, create all ancestor directories.
202+
if make_dir_rwx_recursive(&local.pop())
203+
&& os::rename_file(&clone_target, local) {
204+
Some(local.clone())
203205
}
204206
else {
205-
Some(local.clone())
207+
None
206208
}
207209
}
208210
else {

src/librustpkg/path_util.rs

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ pub static U_RWX: i32 = (S_IRUSR | S_IWUSR | S_IXUSR) as i32;
4343
/// succeeded.
4444
pub fn make_dir_rwx(p: &Path) -> bool { os::make_dir(p, U_RWX) }
4545

46+
pub fn make_dir_rwx_recursive(p: &Path) -> bool { os::mkdir_recursive(p, U_RWX) }
47+
4648
// n.b. The next three functions ignore the package version right
4749
// now. Should fix that.
4850

0 commit comments

Comments
 (0)