summaryrefslogtreecommitdiff
path: root/fbin
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2019-12-08 21:58:18 +0100
committerJon Bergli Heier <snakebite@jvnv.net>2019-12-08 21:58:18 +0100
commitf205f01afc4beb10b84d2c33c2c244a4c4d71619 (patch)
treed965d40d43dd6ea656dd3f9533bcf5155caa00ed /fbin
parentca5cc4e8811a8244422fdfab61254b866b822eee (diff)
filesystem: Fix error on max file size
Move the chmod call into the try block so we always call this when add_file succeeds, otherwise new_file might not be set yet and we will get an UnboundLocalError.
Diffstat (limited to 'fbin')
-rw-r--r--fbin/file_storage/filesystem.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/fbin/file_storage/filesystem.py b/fbin/file_storage/filesystem.py
index 07d29db..3a640bb 100644
--- a/fbin/file_storage/filesystem.py
+++ b/fbin/file_storage/filesystem.py
@@ -24,13 +24,12 @@ class Storage(BaseStorage):
new_file = self.add_file(file_hash, uploaded_file.filename, size, user, ip)
if new_file:
os.rename(temp_path, new_file.get_path())
+ if self.app.config.get('DESTINATION_MODE'):
+ os.chmod(new_file.get_path(), self.app.config.get('DESTINATION_MODE'))
return new_file
except:
os.unlink(temp.name)
raise
- finally:
- if self.app.config.get('DESTINATION_MODE'):
- os.chmod(new_file.get_path(), self.app.config.get('DESTINATION_MODE'))
def get_file(self, f):
path = f.get_path()