summaryrefslogtreecommitdiff
path: root/fbin/file_storage/filesystem.py
AgeCommit message (Collapse)AuthorFilesLines
2021-06-09Fix linting errorsJon Bergli Heier1-3/+4
Style, unused imports, unused variables, etc. as reported by flake8. Configuration for flake8 has been added to setup.cfg.
2021-04-11file_storage.filesystem: Close temp file after saveJon Bergli Heier1-0/+1
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.
2020-10-29Clean up leftover file path referencesJon Bergli Heier1-11/+35
This change removes and direct references to the filesystem from the pyfbin code other that file_storage.filesystem. This should hopyfully be the last changes needed for pyfbin to be successfully run using the file_storage.s3 module without any issues.
2020-10-28Add fbin-backup.pyJon Bergli Heier1-8/+16
This is a backup script which will copy files to a target storage, and optionally add database entries as well. It works by specifying a source and a target config file. Both should have separate storage configured, and files will be copied from the source storage to the target storage. The list of files to copy is read from the source database, which means this must be accessible from where the script is run, not just the storage. If updating databse entries the target database must also be accessible. The target database is also check for any existing file hashes, and any files that would cause a collision will be skipped.
2019-12-08filesystem: Fix error on max file sizeJon Bergli Heier1-3/+2
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.
2019-12-07Add max file size configurationJon Bergli Heier1-1/+2
This allows configuring max file sizes for both registered and anonymous users. For registered users the USER_FILE_SIZE_LIMIT is used, and ANONYMOUS_FILE_SIZE_LIMIT for anonymous users. If the size is not specified or None, the limit is not enforced. Setting the limit to 0 effectively disables uploads.
2019-08-17Fetch and store thumbnails via storage modulesJon Bergli Heier1-0/+15
This will allow us to remotely store thumbnails in case of S3. For S3 the thumb bucket is configurable to allow these to be stored separately. The S3 key for thumbnails does not conflict with files, so these can be stored in the same bucket if needed.
2019-08-17file_storage.filesystem: Set file mode if configuredJon Bergli Heier1-0/+3
Regression since b72ecc321c315bafe40cc7406e87e088564ab8a9. This is needed eg. when using X-Sendfile so that the web server can access the files.
2019-07-24Add file storage modulesJon Bergli Heier1-0/+44
Allows for storing files other places than the local file system. Currently the local filesystem and S3 are supported.