pyfilesystem
pyfilesystem copied to clipboard
[S3] Problem with last_modified
Boto seems to return last_modified in format from Amazon's SOAP interface, not
REST one:
Example key object (taken from inside S3FS._iter_keys):
{'encrypted': None, 'resp': None, 'source_version_id': None, 'owner':
<boto.s3.user.User instance at 0x1094bb098>, 'filename': None, 'size': 5295,
'delete_marker': False, 'etag': u'"f64f18ea21362f8d4b1c63ec6dceb693"',
'content_encoding': None, 'cache_control': None, 'metadata': {}, 'version_id':
None, 'last_modified': u'2011-11-14T21:47:35.000Z', 'content_type':
'application/octet-stream', 'path': None, 'md5': None, 'name': 'blahblah.html',
'bucket': <Bucket: example_bucket>, 'base64md5': None, 'storage_class':
u'STANDARD', 'mode': None, 'Contents': ''}
The last_modified is then parsed with (in S3FS._get_key_info):
fmt = "%a, %d %b %Y %H:%M:%S %Z"
Original issue reported on code.google.com by [email protected] on 14 Nov 2011 at 10:09
This issue is described in https://github.com/boto/boto/issues/466
TL;DR: S3 API calls return the last_modified timestamp in different formats.
Fix is to use boto.utils.parse_ts(), which can handle both formats:
https://github.com/boto/boto/blob/44d873d97bb08a09832b21dcaa0b2d47fe59411b/boto/
utils.py#L460
https://code.google.com/p/pyfilesystem/source/browse/trunk/fs/s3fs.py#584
should be converted to:
if hasattr(key, "last_modified"):
try:
info['modified_time'] = parse_ts(key.last_modified)
except ValueError:
pass
PS. the _get_key_info() contains some source formatting errors and calls a
missing method... Maybe fix those at the same go.
Original comment by [email protected] on 8 Nov 2014 at 2:41