From 128d4136e385b9a43206d71fe4bd44503e0cb0ba Mon Sep 17 00:00:00 2001 From: Miguel Sozinho Ramalho <19508417+msramalho@users.noreply.github.com> Date: Wed, 13 Dec 2023 10:51:25 +0000 Subject: [PATCH] fixes empty api search results (#115) --- src/auto_archiver/databases/api_db.py | 11 ++++++----- src/auto_archiver/version.py | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/auto_archiver/databases/api_db.py b/src/auto_archiver/databases/api_db.py index b772eec..b33b146 100644 --- a/src/auto_archiver/databases/api_db.py +++ b/src/auto_archiver/databases/api_db.py @@ -40,11 +40,12 @@ class AAApiDb(Database): response = requests.get(os.path.join(self.api_endpoint, "tasks/search-url"), params=params, headers=headers) if response.status_code == 200: - logger.success(f"API returned a previously archived instance: {response.json()}") - # TODO: can we do better than just returning the most recent result? - return Metadata.from_dict(response.json()[0]["result"]) - - logger.error(f"AA API FAIL ({response.status_code}): {response.json()}") + if len(response.json()): + logger.success(f"API returned a previously archived instance: {response.json()}") + # TODO: can we do better than just returning the most recent result? + return Metadata.from_dict(response.json()[0]["result"]) + else: + logger.error(f"AA API FAIL ({response.status_code}): {response.json()}") return False diff --git a/src/auto_archiver/version.py b/src/auto_archiver/version.py index 061318b..828e019 100644 --- a/src/auto_archiver/version.py +++ b/src/auto_archiver/version.py @@ -3,7 +3,7 @@ _MAJOR = "0" _MINOR = "7" # On main and in a nightly release the patch should be one ahead of the last # released build. -_PATCH = "3" +_PATCH = "4" # This is mainly for nightly builds which have the suffix ".dev$DATE". See # https://semver.org/#is-v123-a-semantic-version for the semantics. _SUFFIX = ""