From d2ad269df89fbc51b92c50ef38d615d0bc2a01e3 Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Tue, 21 Nov 2023 12:48:18 +0000 Subject: [PATCH] Fix confdir passing to workers --- cista/__main__.py | 2 ++ cista/app.py | 1 - cista/config.py | 3 ++- cista/droppy.py | 1 - 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cista/__main__.py b/cista/__main__.py index 407c60f..f50bfb8 100644 --- a/cista/__main__.py +++ b/cista/__main__.py @@ -1,3 +1,4 @@ +import os import sys from pathlib import Path @@ -117,6 +118,7 @@ def _confdir(args): raise ValueError("Config path is not a directory") # Accidentally pointed to the db.toml, use parent confdir = confdir.parent + os.environ["CISTA_HOME"] = confdir.as_posix() config.conffile = confdir / config.conffile.name diff --git a/cista/app.py b/cista/app.py index 7cad9a4..bdacb03 100644 --- a/cista/app.py +++ b/cista/app.py @@ -36,7 +36,6 @@ app.exception(Exception)(handle_sanic_exception) async def main_start(app, loop): tracemalloc.start() config.load_config() - print(config.config, config.config.public) app.ctx.threadexec = ThreadPoolExecutor( max_workers=3, thread_name_prefix="cista-ioworker" ) diff --git a/cista/config.py b/cista/config.py index 3ecf9af..823451d 100644 --- a/cista/config.py +++ b/cista/config.py @@ -1,5 +1,6 @@ from __future__ import annotations +import os import secrets import sys from functools import wraps @@ -33,7 +34,7 @@ class Link(msgspec.Struct, omit_defaults=True): config = None -conffile = Path.home() / ".local/share/cista/db.toml" +conffile = os.environ.get("CISTA_HOME") or Path.home() / ".local/share/cista/db.toml" def derived_secret(*params, len=8) -> bytes: diff --git a/cista/droppy.py b/cista/droppy.py index cb77d80..3271611 100644 --- a/cista/droppy.py +++ b/cista/droppy.py @@ -5,7 +5,6 @@ import msgspec def readconf() -> dict: p = Path.home() / ".droppy/config" # Hardcoded in Droppy - print("Reading Droppy config", p) cf = msgspec.json.decode((p / "config.json").read_bytes()) db = msgspec.json.decode((p / "db.json").read_bytes()) cf["path"] = p.parent / "files"