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

Skip checksum when download file failed. #3079

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Buguin
Copy link

@Buguin Buguin commented Apr 6, 2023

Fixes #3075
Check if the file is successfully downloaded

nvm.sh Outdated Show resolved Hide resolved
@freddyg11

This comment was marked as spam.

@Xcalibur53 Xcalibur53 linked an issue Apr 21, 2023 that may be closed by this pull request
@ljharb ljharb marked this pull request as draft May 17, 2023 21:34
@ljharb
Copy link
Member

ljharb commented May 17, 2023

@Buguin are you still interested in completing this PR?

@Buguin
Copy link
Author

Buguin commented May 23, 2023

@Buguin are you still interested in completing this PR?

Sorry,I'm too busy working this time. Recently, I will make a push to solve the problem of not being able to return when an error is reported in the following code.

nvm_err "Downloading ${TARBALL_URL}..."
  nvm_download -L -C - "${PROGRESS_BAR}" "${TARBALL_URL}" -o "${TARBALL}" || (
    command rm -rf "${TARBALL}" "${tmpdir}"
    nvm_err "Binary download from ${TARBALL_URL} failed, trying source."
    return 4---it does not work, function not return.
  )

@Buguin
Copy link
Author

Buguin commented May 29, 2023

@Buguin are you still interested in completing this PR?

I have transformed nvm_download_artifact function, which allows you to determine the download status based on the execution results.

@Buguin Buguin marked this pull request as ready for review May 29, 2023 14:24
nvm.sh Outdated
nvm_err "Downloading ${TARBALL_URL}..."
nvm_download -L -C - "${PROGRESS_BAR}" "${TARBALL_URL}" -o "${TARBALL}" || (
download_result=$(nvm_download_v2 -L -C - "${PROGRESS_BAR}" "${TARBALL_URL}" -o "${TARBALL}")
nvm_err "Download Http Status ${download_result}"
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 we don't want to print this in the common success case, and probably not even in the error case. You can, however, wrap it in a NVM_DEBUG check for debugging:

Suggested change
nvm_err "Download Http Status ${download_result}"
if [ "${NVM_DEBUG-}" = 1 ]; then
nvm_err "Download Http Status ${download_result}"
fi

nvm.sh Outdated Show resolved Hide resolved
nvm.sh Outdated Show resolved Hide resolved
Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

This is looking great! Can you come up with some unit tests (one that mocks out nvm_download and tests nvm_download_artifact, and another that mocks out curl/wget and tests nvm_download)?

nvm.sh Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

About install node command [spam]
3 participants