If --preserve was used on upload to S3, then we have the atime and
mtime from stat() already, and that is used.
If --preserve wasn't used, we do still have the last-modified header
we can use. This patch adds that on both get and sync remote2local.
... | ... |
@@ -491,6 +491,10 @@ def cmd_object_get(args): |
491 | 491 |
if response["headers"].has_key("x-amz-meta-s3tools-gpgenc"): |
492 | 492 |
gpg_decrypt(destination, response["headers"]["x-amz-meta-s3tools-gpgenc"]) |
493 | 493 |
response["size"] = os.stat(destination)[6] |
494 |
+ if response["headers"].has_key("last-modified"): |
|
495 |
+ last_modified = time.mktime(time.strptime(response["headers"]["last-modified"], "%a, %d %b %Y %H:%M:%S GMT")) |
|
496 |
+ os.utime(destination, (last_modified, last_modified)) |
|
497 |
+ debug("set mtime to %s" % last_modified) |
|
494 | 498 |
if not Config().progress_meter and destination != "-": |
495 | 499 |
speed_fmt = formatSize(response["speed"], human_readable = True, floating_point = True) |
496 | 500 |
output(u"File %s saved as '%s' (%d bytes in %0.1f seconds, %0.2f %sB/s)" % |
... | ... |
@@ -994,6 +998,10 @@ def cmd_sync_remote2local(args): |
994 | 994 |
uid = int(attrs['uid']) |
995 | 995 |
gid = int(attrs['gid']) |
996 | 996 |
os.lchown(dst_file,uid,gid) |
997 |
+ elif response["headers"].has_key("last-modified"): |
|
998 |
+ last_modified = time.mktime(time.strptime(response["headers"]["last-modified"], "%a, %d %b %Y %H:%M:%S GMT")) |
|
999 |
+ os.utime(dst_file, (last_modified, last_modified)) |
|
1000 |
+ debug("set mtime to %s" % last_modified) |
|
997 | 1001 |
except OSError, e: |
998 | 1002 |
try: |
999 | 1003 |
dst_stream.close() |