Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve condition to ignore empty bucket #454

Merged
merged 1 commit into from
Dec 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 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 @@ -175,8 +175,11 @@ def iter_all_records(

def generator():
for archive in archives:
for record in archive.iter_records(where=where):
yield record
try:
for record in archive.iter_records(where=where):
yield record
except TypeError:
pass

return generator()

Expand All @@ -186,9 +189,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 +211,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
Loading