|
10 | 10 | MAVEN_CENTRAL_REPOSITORY = "https://repo1.maven.org/maven2" |
11 | 11 | REACT_NATIVE_MAVEN_MIRROR_REPOSITORY = "https://repo.reactnative.dev/maven2" |
12 | 12 |
|
| 13 | +# Memoized results of requests to the Maven repositories (mirror or central). |
| 14 | +# hermes-engine.podspec is evaluated several times during a single |
| 15 | +# `pod install`, and every evaluation re-resolves the artifact source from |
| 16 | +# scratch; without memoization that re-issues identical artifact existence |
| 17 | +# probes. The answers should not change within one install, so each request |
| 18 | +# is issued at most once per process. |
| 19 | +HERMES_ARTIFACT_EXISTS_CACHE = {} |
| 20 | + |
13 | 21 | module HermesEngineSourceType |
14 | 22 | LOCAL_PREBUILT_TARBALL = :local_prebuilt_tarball |
15 | 23 | DOWNLOAD_PREBUILD_RELEASE_TARBALL = :download_prebuild_release_tarball |
@@ -339,14 +347,19 @@ def resolve_url_redirects(url) |
339 | 347 |
|
340 | 348 | # This function checks that Hermes artifact exists. |
341 | 349 | # As of now it should check it on the Maven repo. |
| 350 | +# The probe is memoized, so repeated podspec evaluations in one `pod install` |
| 351 | +# don't re-request the same URL. |
342 | 352 | # |
343 | 353 | # Parameters |
344 | 354 | # - version: the version of React Native |
345 | 355 | # - build_type: debug or release |
346 | 356 | def hermes_artifact_exists(tarball_url) |
347 | | - # -L is used to follow redirects, useful for the nightlies |
348 | | - # I also needed to wrap the url in quotes to avoid escaping & and ?. |
349 | | - return (`curl -o /dev/null --silent -Iw '%{http_code}' -L "#{tarball_url}"` == "200") |
| 357 | + unless HERMES_ARTIFACT_EXISTS_CACHE.key?(tarball_url) |
| 358 | + # -L is used to follow redirects, useful for the nightlies |
| 359 | + # I also needed to wrap the url in quotes to avoid escaping & and ?. |
| 360 | + HERMES_ARTIFACT_EXISTS_CACHE[tarball_url] = (`curl -o /dev/null --silent -Iw '%{http_code}' -L "#{tarball_url}"` == "200") |
| 361 | + end |
| 362 | + return HERMES_ARTIFACT_EXISTS_CACHE[tarball_url] |
350 | 363 | end |
351 | 364 |
|
352 | 365 | def hermes_log(message, level = :warning) |
|
0 commit comments