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

Don't download hermes nightly tarball if it exists #36368

Closed
wants to merge 1 commit into from

Conversation

janicduplessis
Copy link
Contributor

Summary

Currently the hermes tarball will be re-downloaded every time we run pod update even if the file already exists. This adds a check to avoid downloading it if it already exists. To avoid partial downloads causing issues (if the script is interrupted) we download first to a different file and rename it when done.

Changelog

[IOS] [FIXED] - Don't download hermes nightly tarball if it exists

Test Plan

Tested in an app using nightly builds that the download is only done once when running multiple pod update.

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Contributor A React Native contributor. labels Mar 3, 2023
@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,508,875 +0
android hermes armeabi-v7a 7,822,846 +0
android hermes x86 8,986,459 +0
android hermes x86_64 8,842,629 +0
android jsc arm64-v8a 9,135,688 +0
android jsc armeabi-v7a 8,325,236 +0
android jsc x86 9,188,636 +0
android jsc x86_64 9,447,626 +0

Base commit: 5746533
Branch: main

Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

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

Looks good to me... I wonder whether we should add a cleanup for the old filepath... 🤔 just not to keep some polluted file system to our users.

Perhaps it is a worthless worries, though...

unless File.exist?(destination_path)
# Download to a temporary file first so we don't cache incomplete downloads.
tmp_file = "#{destination_folder}/hermes-ios.download"
`mkdir -p "#{destination_folder}" && curl "#{tarball_url}" -Lo "#{tmp_file}" && mv "#{tmp_file}" "#{destination_path}"`
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I know it is the same thing, but this makes more evident that we are moving the file.

Suggested change
`mkdir -p "#{destination_folder}" && curl "#{tarball_url}" -Lo "#{tmp_file}" && mv "#{tmp_file}" "#{destination_path}"`
`mkdir -p "#{destination_folder}" && curl "#{tarball_url}" -Lo "#{tmp_file}"`
`mv "#{tmp_file}" "#{destination_path}"`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What if the first command fail, do you know if it would still execute the rename command?

Copy link
Contributor

Choose a reason for hiding this comment

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

You are right, it looks like pod install won't fail and it will continue with the pod installation, with a potentially broken project.

@janicduplessis
Copy link
Contributor Author

It should be fine as it is still in node_modules so when someone updates react-native to a version with this the file will be deleted.

@facebook-github-bot
Copy link
Contributor

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Mar 6, 2023
@facebook-github-bot
Copy link
Contributor

@cipolleschi merged this pull request in d2dd79f.

@janicduplessis janicduplessis deleted the patch-15 branch March 6, 2023 12:48
OlimpiaZurek pushed a commit to OlimpiaZurek/react-native that referenced this pull request May 22, 2023
Summary:
Currently the hermes tarball will be re-downloaded every time we run pod update even if the file already exists. This adds a check to avoid downloading it if it already exists. To avoid partial downloads causing issues (if the script is interrupted) we download first to a different file and rename it when done.

## Changelog

[IOS] [FIXED] - Don't download hermes nightly tarball if it exists

Pull Request resolved: facebook#36368

Test Plan: Tested in an app using nightly builds that the download is only done once when running multiple pod update.

Reviewed By: sshic

Differential Revision: D43815772

Pulled By: cipolleschi

fbshipit-source-id: 9dedb79cab1f1cb37cd82b425d93515c6e1728c1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Contributor A React Native contributor. Merged This PR has been merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants