diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2021-04-11 11:41:45 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2021-04-11 11:41:45 +0200 |
commit | 17c60d0bdf2948a8c55717b34d3231df7cbc141d (patch) | |
tree | 91422a52f80c9565dd5a43a04ecda0139124f90a /fbin | |
parent | 206d304f34434817df610dc849ad62c619b1e60d (diff) |
file_storage.filesystem: Close temp file after save
This will ensure the file content is flushed and lets us get the actual
file size, which will fix very small files being stored with size == 0.
Diffstat (limited to 'fbin')
-rw-r--r-- | fbin/file_storage/filesystem.py | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/fbin/file_storage/filesystem.py b/fbin/file_storage/filesystem.py index 87d908e..b132264 100644 --- a/fbin/file_storage/filesystem.py +++ b/fbin/file_storage/filesystem.py @@ -36,6 +36,7 @@ class Storage(BaseStorage): else: temp = tempfile.NamedTemporaryFile(prefix='upload_', dir=self.app.config['FILE_DIRECTORY'], delete=False) uploaded_file.save(temp.file) + temp.close() temp_path = temp.name size = os.path.getsize(temp_path) new_path = self._get_path(file_hash) |