diff options
-rw-r--r-- | lib/spack/spack/cmd/common/arguments.py | 2 | ||||
-rw-r--r-- | lib/spack/spack/util/s3.py | 15 | ||||
-rw-r--r-- | lib/spack/spack/util/web.py | 2 |
3 files changed, 14 insertions, 5 deletions
diff --git a/lib/spack/spack/cmd/common/arguments.py b/lib/spack/spack/cmd/common/arguments.py index bcfc2866c1..d55b4fbb91 100644 --- a/lib/spack/spack/cmd/common/arguments.py +++ b/lib/spack/spack/cmd/common/arguments.py @@ -403,4 +403,4 @@ def add_s3_connection_args(subparser, add_help): default=None) subparser.add_argument( '--s3-endpoint-url', - help="Access Token to use to connect to this S3 mirror") + help="Endpoint URL to use to connect to this S3 mirror") diff --git a/lib/spack/spack/util/s3.py b/lib/spack/spack/util/s3.py index b52a879e21..6f12e27f6a 100644 --- a/lib/spack/spack/util/s3.py +++ b/lib/spack/spack/util/s3.py @@ -14,9 +14,18 @@ import spack.util.url as url_util def get_mirror_connection(url, url_type="push"): connection = {} # Try to find a mirror for potential connection information - for mirror in spack.mirror.MirrorCollection().values(): - if "%s://%s" % (url.scheme, url.netloc) == mirror.push_url: - connection = mirror.to_dict()[url_type] + # Check to see if desired file starts with any of the mirror URLs + rebuilt_path = url_util.format(url) + # Gather dict of push URLS point to the value of the whole mirror + mirror_dict = {x.push_url: x for x in spack.mirror.MirrorCollection().values()} # noqa: E501 + # Ensure most specific URLs (longest) are presented first + mirror_url_keys = mirror_dict.keys() + mirror_url_keys = sorted(mirror_url_keys, key=len, reverse=True) + for mURL in mirror_url_keys: + # See if desired URL starts with the mirror's push URL + if rebuilt_path.startswith(mURL): + connection = mirror_dict[mURL].to_dict()[url_type] + break return connection diff --git a/lib/spack/spack/util/web.py b/lib/spack/spack/util/web.py index a137c5f6b3..55ff672aea 100644 --- a/lib/spack/spack/util/web.py +++ b/lib/spack/spack/util/web.py @@ -391,7 +391,7 @@ def list_url(url, recursive=False): if os.path.isfile(os.path.join(local_path, subpath))] if url.scheme == 's3': - s3 = s3_util.create_s3_session(url) + s3 = s3_util.create_s3_session(url, connection=s3_util.get_mirror_connection(url)) # noqa: E501 if recursive: return list(_iter_s3_prefix(s3, url)) |