-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Use mktemp for temporary download directory #19227
Conversation
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.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @huonw (or someone else) soon. |
Does it not suffice to simply Apart from that, you really need to check if TMP_DIR=`mktemp -d` || exit 1 There are several invocation of |
If mktemp fails, fall back to a hard coded directory, per @nodakai's feedback.
@nodakai Thanks for taking a look! Good point about exiting if it fails. I made a fallback to the current bahavior if I didn't think about the HTTP resume scenario, but it doesn't seem like rustup is trying to do that—it deletes the folder up front.
Yes, I could definitely just do that. It just didn't seem right to me to pollute the current directory (whatever that might be) with a To be honest, this isn't a big deal to me; I can always work around it. I just assume that someone else will have simlar issues. |
/cc @brson |
Will probably need a rebase after #19170 lands. |
#19170 has landed (19 days ago) and this just needs a rebase at this point |
Conflicts: src/etc/rustup.sh
@frewsxcv Thanks for the heads up. Merged master into the fork. |
@@ -401,7 +413,7 @@ then | |||
CFG_INSTALL_FLAGS="${CFG_INSTALL_FLAGS} --prefix=${CFG_PREFIX}" | |||
fi | |||
|
|||
CFG_TMP_DIR="./rustup-tmp-install" | |||
CFG_TMP_DIR=`mktemp -d 2>/dev/null || mktemp -d -t 'rustup-tmp-install' 2>/dev/null` || CFG_TMP_DIR=$(create_tmp_dir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is over 100 characters long, which fails the style checker
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably use $()
instead of backticks, but it must certainly be quoted.
@frewsxcv Thanks again for the feedback. I split the line into three lines. Not sure if it matches the style guide (if you even have one for bash). @tbu- I changed it to use |
@johshoff Yea, I was wrong about the needed quotation. Thanks for the change to |
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.
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.