summaryrefslogtreecommitdiff
path: root/fbin/file_storage
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2019-12-07 11:19:00 +0100
committerJon Bergli Heier <snakebite@jvnv.net>2019-12-07 11:19:00 +0100
commitca5cc4e8811a8244422fdfab61254b866b822eee (patch)
treed93073f45fe3d2d5f9dec12ba06f7eddc140841b /fbin/file_storage
parentf1cfaef5b0f358c94fe7f5e7c2eb5a6d261a85ae (diff)
s3: Delete file if add_file raises an exception
Diffstat (limited to 'fbin/file_storage')
-rw-r--r--fbin/file_storage/s3.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/fbin/file_storage/s3.py b/fbin/file_storage/s3.py
index 9e68186..a11488f 100644
--- a/fbin/file_storage/s3.py
+++ b/fbin/file_storage/s3.py
@@ -29,7 +29,11 @@ class Storage(BaseStorage):
if not size:
obj = self.client.ObjectSummary(self.app.config['S3_BUCKET'], key)
size = obj.size
- return self.add_file(file_hash, uploaded_file.filename, size, user, ip)
+ try:
+ return self.add_file(file_hash, uploaded_file.filename, size, user, ip)
+ except:
+ obj.delete()
+ raise
def get_file(self, f, thumb=False):
key = self.get_object_key(f, thumb=thumb)