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/__init__.py | |
| 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/__init__.py')
| -rw-r--r-- | uploader/__init__.py | 17 |
1 files changed, 15 insertions, 2 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. |
