Skip to content

Commit

Permalink
Don't download hermes nightly tarball if it exists (#36368)
Browse files Browse the repository at this point in the history
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: #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
  • Loading branch information
janicduplessis authored and facebook-github-bot committed Mar 6, 2023
1 parent aac7150 commit d2dd79f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sdks/hermes-engine/hermes-utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,13 @@ def download_nightly_hermes(react_native_path, version)
tarball_url = nightly_tarball_url(version)

destination_folder = "#{react_native_path}/sdks/downloads"
destination_path = "#{destination_folder}/hermes-ios.tar.gz"
destination_path = "#{destination_folder}/hermes-ios-#{version}.tar.gz"

`mkdir -p "#{destination_folder}" && curl "#{tarball_url}" -Lo "#{destination_path}"`
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}"`
end
return destination_path
end

Expand Down

0 comments on commit d2dd79f

Please sign in to comment.