Skip to content

Commit cb50153

Browse files
committed
Use mktemp for temporary download directory
Using the current directory may not always be appropriate, for example in the case where it will unnecessarily trigger a backup to be made. The only risk with this change is that systems might not have a mktemp. I am not aware of such a system, but have not tested on Windows. It is working on a basic Ubuntu and OS X installation.
1 parent 0d0a290 commit cb50153

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

src/etc/rustup.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ PACKAGE_NAME=rust-nightly
392392
PACKAGE_NAME_AND_TRIPLE="${PACKAGE_NAME}-${HOST_TRIPLE}"
393393
TARBALL_NAME="${PACKAGE_NAME_AND_TRIPLE}.tar.gz"
394394
REMOTE_TARBALL="https://static.rust-lang.org/dist/${TARBALL_NAME}"
395-
TMP_DIR="./rustup-tmp-install"
395+
TMP_DIR=`mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir'`
396396
LOCAL_TARBALL="${TMP_DIR}/${TARBALL_NAME}"
397397
LOCAL_INSTALL_DIR="${TMP_DIR}/${PACKAGE_NAME_AND_TRIPLE}"
398398
LOCAL_INSTALL_SCRIPT="${LOCAL_INSTALL_DIR}/install.sh"
@@ -405,12 +405,6 @@ CARGO_LOCAL_TARBALL="${TMP_DIR}/${CARGO_TARBALL_NAME}"
405405
CARGO_LOCAL_INSTALL_DIR="${TMP_DIR}/${CARGO_PACKAGE_NAME_AND_TRIPLE}"
406406
CARGO_LOCAL_INSTALL_SCRIPT="${CARGO_LOCAL_INSTALL_DIR}/install.sh"
407407

408-
rm -Rf "${TMP_DIR}"
409-
need_ok "failed to remove temporary installation directory"
410-
411-
mkdir -p "${TMP_DIR}"
412-
need_ok "failed to create create temporary installation directory"
413-
414408
msg "downloading rust installer"
415409
"${CFG_CURL}" "${REMOTE_TARBALL}" > "${LOCAL_TARBALL}"
416410
if [ $? -ne 0 ]

0 commit comments

Comments
 (0)