#2354 backend: don't traceback when there are no files in the S3 storage
Merged 2 years ago by praiskup. Opened 2 years ago by frostyx.
copr/ frostyx/copr aws-hitcounter-empty  into  main

@@ -68,7 +68,7 @@ 

  

          result = []

          for page in page_iterator:

-             for obj in page["Contents"]:

+             for obj in page.get("Contents", []):

                  result.append(obj["Key"])

          return result

  

When this commands returns zero:

aws s3 ls s3://fedora-copr/cloudwatch/ |wc -l

We get the following traceback:

Traceback (most recent call last):
File "/usr/bin/copr-aws-s3-hitcounter", line 248, in <module>
    main()
File "/usr/bin/copr-aws-s3-hitcounter", line 216, in main
    files = s3.list_files()
File "/usr/bin/copr-aws-s3-hitcounter", line 71, in list_files
    for obj in page["Contents"]:
KeyError: 'Contents'

Build succeeded.

Commit c107ac5 fixes this pull-request

Pull-Request has been merged by praiskup

2 years ago
Metadata