Skip to content

Commit

Permalink
Add condition to ignore empty bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaslinhares committed Dec 21, 2023
1 parent d8dbadf commit 3f6568c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions temba/archives/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def get_download_link(self):
if self.url:
s3_client = s3.client()
bucket, key = self.get_storage_location()
if bucket == "":
if not bucket:
return ""
s3_params = {
"Bucket": bucket,
Expand Down Expand Up @@ -173,10 +173,12 @@ def iter_all_records(

archives = cls._get_covering_period(org, archive_type, after, before)

# Random comment to verify if we are changing the image
def generator():
for archive in archives:
for record in archive.iter_records(where=where):
yield record
if archive:
for record in archive.iter_records(where=where):
yield record

return generator()

Expand All @@ -186,9 +188,12 @@ def iter_records(self, *, where: dict = None):
"""

s3_client = s3.client()
bucket, key = self.get_storage_location()

if not bucket:
return

if where:
bucket, key = self.get_storage_location()
response = s3_client.select_object_content(
Bucket=bucket,
Key=key,
Expand All @@ -205,7 +210,6 @@ def generator():
return generator()

else:
bucket, key = self.get_storage_location()
s3_obj = s3_client.get_object(Bucket=bucket, Key=key)
return jsonlgz_iterate(s3_obj["Body"])

Expand Down

0 comments on commit 3f6568c

Please sign in to comment.