Skip to content

Commit

Permalink
Merge pull request #98 from orenhe/master
Browse files Browse the repository at this point in the history
Prevent 's3cmd get' from leaving dangling empty files on failure
  • Loading branch information
mludvig committed Jan 1, 2013
2 parents 19a529a + 1a05156 commit a91c40f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion s3cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit a91c40f

Please sign in to comment.