-
-
Notifications
You must be signed in to change notification settings - Fork 8k
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
Improve nvm_download_artifact() process, fix #1291 #1294
Conversation
PeterDaveHello
commented
Nov 7, 2016
- Delete broken/checksum not matched local cache
- More output message.
local USE_LOCAL_TARBALL | ||
if [ -r "${TARBALL}" ]; then | ||
nvm_err "Local cache found:" | ||
nvm_err "$(nvm_sanitize_path "${TARBALL}")" |
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.
let's collapse this into the preceding line, to keep output minimal.
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.
hmmmm ... the reason why I put them into two is because ${TARBALL}
is a little bit too long, what do you think?
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.
@ljharb ?
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.
I wouldn't really be concerned with line length - long lines wrap, and the important part would be in the front.
else | ||
nvm_compare_checksum "${TARBALL}" "${CHECKSUM}" | ||
nvm_err "Checksum check failed!" | ||
nvm_err "Removing the broken local cache ..." |
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.
also here; let's collapse this with the previous line. also, no space before the three dots :-)
nvm_err "$(nvm_sanitize_path "${TARBALL}")" | ||
if nvm_compare_checksum "${TARBALL}" "${CHECKSUM}" >/dev/null 2>&1; then | ||
nvm_err "Checksums match! Using existing downloaded archive $(nvm_sanitize_path "${TARBALL}")" | ||
USE_LOCAL_TARBALL="true" |
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.
No need to set it to the string true; just true
should be sufficient
nvm_err "Checksum check failed!" | ||
nvm_err "Removing the broken local cache ..." | ||
command rm -rf "${TARBALL}" | ||
nvm_err "Downloading ${TARBALL_URL} ..." |
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 redundant since line 1744 does the same thing
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.
@ljharb but line 1744 will be hidden, so the user will just see the progress bar without downloading info, is this fine?
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.
@ljharb ?
nvm_err "Downloading ${TARBALL_URL} ..." | ||
fi | ||
fi | ||
if [ "${USE_LOCAL_TARBALL-}" != "true" ]; then |
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.
i think rather than using USE_LOCAL_TARBALL
, we could add nvm_echo "${TARBALL}"
and return 0
to the previous "if" block, and then remove this nesting?
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.
Do you mean insert return 0
to this if
block?
if nvm_compare_checksum "${TARBALL}" "${CHECKSUM}" >/dev/null 2>&1; then
Thanks
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.
i mean insert both of these:
nvm_echo "${TARBALL}"
return 0
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.
like this? I not sure about if I understand this part
if nvm_compare_checksum "${TARBALL}" "${CHECKSUM}" >/dev/null 2>&1; then
nvm_err "Checksums match! Using existing downloaded archive $(nvm_sanitize_path "${TARBALL}")" USE_LOCAL_TARBALL=true
nvm_echo "${TARBALL}"
return 0
else
nvm_compare_checksum "${TARBALL}" "${CHECKSUM}" nvm_err "Checksum check failed!"
nvm_err "Removing the broken local cache..."
command rm -rf "${TARBALL}"
nvm_err "Downloading ${TARBALL_URL} ..."
fi
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.
yep! except that now you can change else
to fi
, remove the final fi
, and de-indent the erstwhile "else" code
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.
Oops, I might not catch it, now I got your point 😄
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.
Updated!
b79a477
to
01cb746
Compare
local USE_LOCAL_TARBALL | ||
if [ -r "${TARBALL}" ]; then | ||
nvm_err "Local cache found:" | ||
nvm_err "$(nvm_sanitize_path "${TARBALL}")" |
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.
I wouldn't really be concerned with line length - long lines wrap, and the important part would be in the front.
command rm -rf "${TARBALL}" | ||
nvm_err "Downloading ${TARBALL_URL} ..." | ||
fi | ||
if [ "${USE_LOCAL_TARBALL-}" != true ]; then |
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.
now that you've denested, we no longer need this variable at all - please remove it, and denest lines 1745-1761.
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.
oops, my fault ... thanks.
01cb746
to
f9dc1e0
Compare
Fixed. |
command rm -rf "${TARBALL}" | ||
nvm_err "Downloading ${TARBALL_URL} ..." | ||
fi | ||
nvm_echo "Downloading ${TARBALL_URL}..." |
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.
line 1739 and 1741 will both execute in this case - i think 1741 should use nvm_err
and 1739 should be removed.
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.
Nice!
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.
Updated!
- Delete broken/checksum not matched local cache - More output message.
f9dc1e0
to
c5303a6
Compare