diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2021-06-09 18:17:27 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2021-06-09 18:17:27 +0200 |
commit | 7c13b1038482d68c2ab581dad16fa81c0a09034e (patch) | |
tree | 9e7ac314c1766a560e8d17c3864095c1540a62fc /fbin | |
parent | 17c60d0bdf2948a8c55717b34d3231df7cbc141d (diff) |
file_storage.s3: Fix deleting object on file_add error
Make sure obj is returned from upload_file so that we can delete it if
add_file raises an exception.
Diffstat (limited to 'fbin')
-rw-r--r-- | fbin/file_storage/s3.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/fbin/file_storage/s3.py b/fbin/file_storage/s3.py index e2dd1ea..71ee1e7 100644 --- a/fbin/file_storage/s3.py +++ b/fbin/file_storage/s3.py @@ -29,10 +29,10 @@ class Storage(BaseStorage): if not size: obj = self.client.ObjectSummary(self.app.config['S3_BUCKET'], key) size = obj.size - return size + return obj, size def store_file(self, uploaded_file, file_hash, user, ip): - size = self.upload_file(uploaded_file, file_hash, user) + obj, size = self.upload_file(uploaded_file, file_hash, user) try: return self.add_file(file_hash, uploaded_file.filename, size, user, ip) except: |