Page MenuHomeSoftware Heritage

D8626.diff
No OneTemporary

D8626.diff

diff --git a/swh/lister/nixguix/lister.py b/swh/lister/nixguix/lister.py
--- a/swh/lister/nixguix/lister.py
+++ b/swh/lister/nixguix/lister.py
@@ -157,22 +157,12 @@
if urlparsed.scheme not in ("http", "https", "ftp"):
raise ArtifactNatureMistyped(f"Mistyped artifact '{url}'")
- errors = []
- query_params = dict(parse_qsl(urlparsed.query))
- for path in [query_params.get(key) for key in ["f", "file", "url", "name"]] + [
- urlparsed.path
- ]:
- if not path:
- continue
- try:
- file_ = Path(path).suffixes[-1]
- break
- except IndexError as e:
- errors.append(ArtifactWithoutExtension(e))
-
- if errors:
- raise errors[-1]
- return file_.lstrip(".") in TARBALL_EXTENSIONS
+ paths = [
+ Path(p) for (_, p) in [("_", urlparsed.path)] + parse_qsl(urlparsed.query)
+ ]
+ if not any(path.suffix != "" for path in paths):
+ raise ArtifactWithoutExtension
+ return any(path.suffix.endswith(tuple(TARBALL_EXTENSIONS)) for path in paths)
index = random.randrange(len(urls))
url = urls[index]
diff --git a/swh/lister/nixguix/tests/test_lister.py b/swh/lister/nixguix/tests/test_lister.py
--- a/swh/lister/nixguix/tests/test_lister.py
+++ b/swh/lister/nixguix/tests/test_lister.py
@@ -47,7 +47,7 @@
@pytest.mark.parametrize(
"query_param",
- ["file", "f", "url", "name"],
+ ["file", "f", "url", "name", "anykeyreally"],
)
def test_is_tarball_not_so_simple(query_param):
"""More involved check on tarball should discriminate between tarball and file"""

File Metadata

Mime Type
text/plain
Expires
Nov 5 2024, 4:20 AM (8 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3216988

Event Timeline