Skip to content
Browse files

Merge pull request #98 from orenhe/master

Prevent 's3cmd get' from leaving dangling empty files on failure
  • Loading branch information...
2 parents 19a529a + 1a05156 commit a91c40fcd14772fa48297e676c8c6efa1aabc3c0 @mludvig mludvig committed Dec 31, 2012
Showing with 8 additions and 1 deletion.
  1. +8 −1 s3cmd
View
9 s3cmd
@@ -440,7 +440,14 @@ def cmd_object_get(args):
except IOError, e:
error(u"Skipping %s: %s" % (destination, e.strerror))
continue
- response = s3.object_get(uri, dst_stream, start_position = start_position, extra_label = seq_label)
+ try:
+ response = s3.object_get(uri, dst_stream, start_position = start_position, extra_label = seq_label)
+ except S3Error, e:
+ if not file_exists: # Delete, only if file didn't exist before!
+ debug(u"object_get failed for '%s', deleting..." % (destination,))
+ os.unlink(destination)
+ raise
+
if response["headers"].has_key("x-amz-meta-s3tools-gpgenc"):
gpg_decrypt(destination, response["headers"]["x-amz-meta-s3tools-gpgenc"])
response["size"] = os.stat(destination)[6]

0 comments on commit a91c40f

Please sign in to comment.
Something went wrong with that request. Please try again.