Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursively create the target directory before renaming a cloned git repository in rustpkg install #9148

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
12 changes: 7 additions & 5 deletions src/librustpkg/package_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use context::*;
use crate::Crate;
use messages::*;
use source_control::{git_clone, git_clone_general};
use path_util::{find_dir_using_rust_path_hack, default_workspace};
use path_util::{find_dir_using_rust_path_hack, default_workspace, make_dir_rwx_recursive};
use util::compile_crate;
use workspace::is_workspace;
use workcache_support;
Expand Down Expand Up @@ -166,12 +166,14 @@ impl PkgSrc {
url, clone_target.to_str(), pkgid.version.to_str());

if git_clone_general(url, &clone_target, &pkgid.version) {
// since the operation succeeded, move clone_target to local
if !os::rename_file(&clone_target, local) {
None
// Since the operation succeeded, move clone_target to local.
// First, create all ancestor directories.
if make_dir_rwx_recursive(&local.pop())
&& os::rename_file(&clone_target, local) {
Some(local.clone())
}
else {
Some(local.clone())
None
}
}
else {
Expand Down
2 changes: 2 additions & 0 deletions src/librustpkg/path_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ pub static U_RWX: i32 = (S_IRUSR | S_IWUSR | S_IXUSR) as i32;
/// succeeded.
pub fn make_dir_rwx(p: &Path) -> bool { os::make_dir(p, U_RWX) }

pub fn make_dir_rwx_recursive(p: &Path) -> bool { os::mkdir_recursive(p, U_RWX) }

// n.b. The next three functions ignore the package version right
// now. Should fix that.

Expand Down