lericson / simples3

Simple, quick Amazon AWS S3 interface in Python
BSD 2-Clause "Simplified" License
96 stars 36 forks source link

HTTP 204 returned on S3Bucket.delete #5

Closed olaf7 closed 12 years ago

olaf7 commented 13 years ago
Traceback (most recent call last):
  File "./s3sync_olaf.sh", line 317, in <module>
    main() 
  File "./s3sync_olaf.sh", line 301, in main
    trim_bucket(bucket)
  File "./s3sync_olaf.sh", line 116, in trim_bucket
    del s3b[key]
  File "/usr/lib/pymodules/python2.5/simples3/bucket.py", line 157, in __delitem__
    def __delitem__(self, name): return self.delete(name)
  File "/usr/lib/pymodules/python2.5/simples3/bucket.py", line 296, in delete
    resp = self.make_request("DELETE", key=key)
  File "/usr/lib/pymodules/python2.5/simples3/bucket.py", line 259, in make_request
    raise exc_cls.from_urllib(e, key=key)
simples3.bucket.S3Error: HTTP error (code=204, key='space/ourproject-2011-04-24.tar.gz', filename='http://s3.amazonaws.com/Assembla-space-ourproject/space/ourproject-2011-04-24.tar.gz')

I use the S3Bucket.listdir API call a lot. It gives a list of files. I iterate through it and check the filedate if it is an old file I run del s3b[key]. That command is on a separate line, and is the line triggering the exception.

Basically:

for (k, modify, etag, size) in b.listdir(...):
    if predicate(modify):
        del b[k]
lericson commented 13 years ago

The proper coures of action here would seem to be triggering no error.

Perhaps you could create a test for this? In tests/test_bucket.py there is a test case called DeleteTests, I suggest adding a test here. Will you champion this or can I consider this deferred until a later date?

olaf7 commented 12 years ago

Sorry I took so very long to reply. Did not have the time before to commence further on the project. Issue is not there when using Python 2.6 instead of 2.5. Just like the remark in simples3/bucket.py about HTTP 204 suggests.