diff --git a/swh/loader/package/archive/loader.py b/swh/loader/package/archive/loader.py --- a/swh/loader/package/archive/loader.py +++ b/swh/loader/package/archive/loader.py @@ -1,4 +1,4 @@ -# Copyright (C) 2019-2021 The Software Heritage developers +# Copyright (C) 2019-2022 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information @@ -145,7 +145,11 @@ parsed_time = iso8601.parse_date(time) else: parsed_time = time - normalized_time = TimestampWithTimezone.from_datetime(parsed_time) + normalized_time = ( + TimestampWithTimezone.from_datetime(parsed_time) + if parsed_time is not None + else None + ) msg = f"Synthetic release for archive at {p_info.url}\n" return Release( name=p_info.version.encode(), diff --git a/swh/loader/package/archive/tests/test_archive.py b/swh/loader/package/archive/tests/test_archive.py --- a/swh/loader/package/archive/tests/test_archive.py +++ b/swh/loader/package/archive/tests/test_archive.py @@ -1,8 +1,9 @@ -# Copyright (C) 2019-2021 The Software Heritage developers +# Copyright (C) 2019-2022 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information +import copy import datetime import hashlib from io import BytesIO @@ -486,3 +487,16 @@ snapshot = loader.last_snapshot() assert len(snapshot.branches) == 2 assert b"releases/0.1.0" in snapshot.branches + + +def test_archive_visit_no_time_for_tarball(swh_storage, requests_mock_datadir): + artifacts = copy.deepcopy(GNU_ARTIFACTS) + for artifact in artifacts: + artifact["time"] = None + + loader = ArchiveLoader(swh_storage, URL, artifacts=artifacts) + + actual_load_status = loader.load() + assert actual_load_status["status"] == "eventful" + + assert_last_visit_matches(swh_storage, URL, status="full", type="tar")