From 85fe22047039f8d25ad6102b6d8bf8d4581da3ad Mon Sep 17 00:00:00 2001 From: Aaron Suggs Date: Sun, 4 Mar 2012 19:38:19 -0500 Subject: [PATCH] [aws|storage] Automatically abort multipart uploads on exceptions --- lib/fog/aws/models/storage/file.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/fog/aws/models/storage/file.rb b/lib/fog/aws/models/storage/file.rb index 94a0a23f8..9991af648 100644 --- a/lib/fog/aws/models/storage/file.rb +++ b/lib/fog/aws/models/storage/file.rb @@ -176,6 +176,11 @@ module Fog part_tags << part_upload.headers["ETag"] end + rescue + # Abort the upload & reraise + connection.abort_multipart_upload(directory.key, key, upload_id) if upload_id + raise + else # Complete the upload connection.complete_multipart_upload(directory.key, key, upload_id, part_tags) end