diff options
| author | Benjamin Herr <ben@0x539.de> | 2013-10-11 15:55:37 +0200 |
|---|---|---|
| committer | Benjamin Herr <ben@0x539.de> | 2013-10-11 15:55:37 +0200 |
| commit | 63e9e496f65cac6b9f22abda7f2f0ffa1af0cf94 (patch) | |
| tree | 25ba34476090f29fdd14838e84c94ee0b61f40d8 /src/librustpkg/source_control.rs | |
| parent | 5bddcc1eadeafd2461f7026d7c1f5c70980c1f06 (diff) | |
| download | rust-63e9e496f65cac6b9f22abda7f2f0ffa1af0cf94.tar.gz rust-63e9e496f65cac6b9f22abda7f2f0ffa1af0cf94.zip | |
extra::tempfile: replace mkdtemp with an RAII wrapper
this incidentally stops `make check` from leaving directories in `/tmp`
Diffstat (limited to 'src/librustpkg/source_control.rs')
| -rw-r--r-- | src/librustpkg/source_control.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/librustpkg/source_control.rs b/src/librustpkg/source_control.rs index 877247bccad..33b86e7cbc5 100644 --- a/src/librustpkg/source_control.rs +++ b/src/librustpkg/source_control.rs @@ -12,7 +12,7 @@ use std::{io, os, run, str}; use std::run::{ProcessOutput, ProcessOptions, Process}; -use extra::tempfile; +use extra::tempfile::TempDir; use version::*; use path_util::chmod_read_only; @@ -22,14 +22,6 @@ use path_util::chmod_read_only; /// directory (that the callee may use, for example, to check out remote sources into). /// Returns `CheckedOutSources` if the clone succeeded. pub fn safe_git_clone(source: &Path, v: &Version, target: &Path) -> CloneResult { - use conditions::failed_to_create_temp_dir::cond; - - let scratch_dir = tempfile::mkdtemp(&os::tmpdir(), "rustpkg"); - let clone_target = match scratch_dir { - Some(d) => d.push("rustpkg_temp"), - None => cond.raise(~"Failed to create temporary directory for fetching git sources") - }; - if os::path_exists(source) { debug2!("{} exists locally! Cloning it into {}", source.to_str(), target.to_str()); @@ -77,6 +69,14 @@ pub fn safe_git_clone(source: &Path, v: &Version, target: &Path) -> CloneResult } CheckedOutSources } else { + use conditions::failed_to_create_temp_dir::cond; + + let scratch_dir = TempDir::new("rustpkg"); + let clone_target = match scratch_dir { + Some(d) => d.unwrap().push("rustpkg_temp"), + None => cond.raise(~"Failed to create temporary directory for fetching git sources") + }; + DirToUse(clone_target) } } |
