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

Improve nvm_download_artifact() process, fix #1291 #1294

Merged
merged 1 commit into from
Nov 12, 2016

Conversation

PeterDaveHello
Copy link
Collaborator

  • 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}")"
Copy link
Member

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.

Copy link
Collaborator Author

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

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 ..."
Copy link
Member

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"
Copy link
Member

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} ..."
Copy link
Member

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

Copy link
Collaborator Author

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nvm_err "Downloading ${TARBALL_URL} ..."
fi
fi
if [ "${USE_LOCAL_TARBALL-}" != "true" ]; then
Copy link
Member

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?

Copy link
Collaborator Author

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

Copy link
Member

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

Copy link
Collaborator Author

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

Copy link
Member

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

Copy link
Collaborator Author

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 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated!

local USE_LOCAL_TARBALL
if [ -r "${TARBALL}" ]; then
nvm_err "Local cache found:"
nvm_err "$(nvm_sanitize_path "${TARBALL}")"
Copy link
Member

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
Copy link
Member

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, my fault ... thanks.

@PeterDaveHello
Copy link
Collaborator Author

Fixed.

command rm -rf "${TARBALL}"
nvm_err "Downloading ${TARBALL_URL} ..."
fi
nvm_echo "Downloading ${TARBALL_URL}..."
Copy link
Member

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Copy link
Collaborator Author

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.
@ljharb ljharb added the installing node Issues with installing node/io.js versions. label Nov 12, 2016
@ljharb ljharb merged commit c5303a6 into nvm-sh:master Nov 12, 2016
@PeterDaveHello PeterDaveHello deleted the local-cache-improve branch November 12, 2016 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
installing node Issues with installing node/io.js versions.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants