diff options
Diffstat (limited to 'uploader')
| -rw-r--r-- | uploader/__init__.py | 17 | ||||
| -rw-r--r-- | uploader/default_settings.py | 3 |
2 files changed, 17 insertions, 3 deletions
diff --git a/uploader/__init__.py b/uploader/__init__.py index a28ed8d..32eabba 100644 --- a/uploader/__init__.py +++ b/uploader/__init__.py @@ -78,9 +78,22 @@ def __setup_scratch_directory__(app: Flask) -> Flask: app.config["SCRATCH_DIRECTORY"]).absolute() return app -def update_unspecified_defaults(app: Flask): +def __setup_upload_directory__(app: Flask) -> Flask: + if app.config.get("UPLOAD_DIRECTORY", "").strip() == "": + app.config["UPLOAD_DIRECTORY"] = app.config[ + "SCRATCH_DIRECTORY"].joinpath("uploads") + else: + app.config["UPLOAD_DIRECTORY"] = Path( + app.config["UPLOAD_DIRECTORY"].strip()).absolute() + + return app + + +def update_unspecified_defaults(app: Flask) -> Flask: """Setup the defaults for necessary configurations that do not have values specified for them.""" - __setup_scratch_directory__(app) + return __setup_upload_directory__(__setup_scratch_directory__(app)) + + def create_app(config: Optional[dict] = None): """The application factory. diff --git a/uploader/default_settings.py b/uploader/default_settings.py index 75dc53a..0ac12e5 100644 --- a/uploader/default_settings.py +++ b/uploader/default_settings.py @@ -5,13 +5,14 @@ actual configuration file used for the production and staging systems. LOG_LEVEL = "WARNING" SECRET_KEY = b"<Please! Please! Please! Change This!>" -UPLOAD_FOLDER = "/tmp/qc_app_files" # Scratch directory and uploads: # *** The scratch directory *** # We avoid `/tmp` entirely for the scratch directory to avoid shared global # mutable state with other users/applications/processes. SCRATCH_DIRECTORY = "~/tmp/gn-uploader-scratchdir" +UPLOAD_FOLDER = ""# If not set, will be under scratch directory. + REDIS_URL = "redis://" JOBS_TTL_SECONDS = 1209600 # 14 days GNQC_REDIS_PREFIX="gn-uploader" |
