about summary refs log tree commit diff
path: root/uploader/__init__.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2026-01-26 13:52:57 -0600
committerFrederick Muriuki Muriithi2026-01-26 14:11:38 -0600
commit49c3f72fa0f9f68e463d8a883b3d1786ec4c0768 (patch)
treecd407ac9bb8411eb3df9d8a2d522c56ae21bff44 /uploader/__init__.py
parent79386454b1d87d5b4c1ace22e7b272a71fd205be (diff)
downloadgn-uploader-49c3f72fa0f9f68e463d8a883b3d1786ec4c0768.tar.gz
Replace TEMPORARY_DIRECTORY with SCRATCH_DIRECTORY
Avoid using the terminology "TEMPORARY_DIRECTORY" which encourages use
of the shared global mutable state in /tmp, that we want to move away
from. Instead, we use "SCRATCH_DIRECTORY" which is an explicit
specified directory for state needed for and by the gn-uploader
application.
Diffstat (limited to 'uploader/__init__.py')
-rw-r--r--uploader/__init__.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/uploader/__init__.py b/uploader/__init__.py
index 0ba1f81..a28ed8d 100644
--- a/uploader/__init__.py
+++ b/uploader/__init__.py
@@ -73,6 +73,14 @@ 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 update_unspecified_defaults(app: Flask):
+    """Setup the defaults for necessary configurations that do not have values specified for them."""
+    __setup_scratch_directory__(app)
 def create_app(config: Optional[dict] = None):
     """The application factory.
 
@@ -100,6 +108,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(