diff options
| author | Frederick Muriuki Muriithi | 2026-01-26 13:55:28 -0600 |
|---|---|---|
| committer | Frederick Muriuki Muriithi | 2026-01-26 14:23:59 -0600 |
| commit | 5705666ac0025ecc83c9cdb4ee0ebf94983ee069 (patch) | |
| tree | 8b05d7089a7c6bc22a32db977f2ee34a6606d6e9 /uploader | |
| parent | 49c3f72fa0f9f68e463d8a883b3d1786ec4c0768 (diff) | |
| download | gn-uploader-5705666ac0025ecc83c9cdb4ee0ebf94983ee069.tar.gz | |
Move the UPLOAD_DIRECTORY under the SCRATCH_DIRECTORY by default.
If the UPLOAD_DIRECTORY is not specified in the configuration file(s), then, by default, have it under the SCRATCH_DIRECTORY.
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" |
