about summary refs log tree commit diff
path: root/uploader/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'uploader/__init__.py')
-rw-r--r--uploader/__init__.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/uploader/__init__.py b/uploader/__init__.py
index 0ba1f81..46689c5 100644
--- a/uploader/__init__.py
+++ b/uploader/__init__.py
@@ -73,6 +73,28 @@ def setup_modules_logging(app_logger, modules):
         _logger.setLevel(loglevel)
 
 
+def __setup_scratch_directory__(app: Flask) -> Flask:
+    app.config["SCRATCH_DIRECTORY"] = Path(
+        app.config["SCRATCH_DIRECTORY"]).absolute()
+    return app
+
+def __setup_upload_directory__(app: Flask) -> Flask:
+    if app.config.get("UPLOADS_DIRECTORY", "").strip() == "":
+        app.config["UPLOADS_DIRECTORY"] = app.config[
+            "SCRATCH_DIRECTORY"].joinpath("uploads")
+    else:
+        app.config["UPLOADS_DIRECTORY"] = Path(
+            app.config["UPLOADS_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."""
+    return __setup_upload_directory__(__setup_scratch_directory__(app))
+
+
 def create_app(config: Optional[dict] = None):
     """The application factory.
 
@@ -100,6 +122,7 @@ def create_app(config: Optional[dict] = None):
             # Silently ignore secrets if the file does not exist.
             app.config.from_pyfile(secretsfile)
     app.config.update(config) # Override everything with passed in config
+    update_unspecified_defaults(app)
     ### END: Application configuration
 
     app.config["SESSION_CACHELIB"] = FileSystemCache(