From c1dd25fb2173234f460a16d274c970c5d56988a2 Mon Sep 17 00:00:00 2001 From: Nick Mowen Date: Sat, 28 May 2022 08:51:12 -0600 Subject: [PATCH] Create db path if it does not exist --- swatch/app.py | 4 ++++ swatch/snapshot.py | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/swatch/app.py b/swatch/app.py index 4bb48b9..7d1ef9b 100644 --- a/swatch/app.py +++ b/swatch/app.py @@ -60,6 +60,10 @@ def __init_db__(self): """Init the Swatch database.""" db_file = os.environ.get("DB_FILE", CONST_DB_FILE) + if not os.path.exists(db_file): + logging.debug(f"{db_file} doesn't exist, creating...") + os.makedirs(db_file) + swatch_db = SqliteExtDatabase(db_file) router = Router(swatch_db) diff --git a/swatch/snapshot.py b/swatch/snapshot.py index 5376089..43a368d 100644 --- a/swatch/snapshot.py +++ b/swatch/snapshot.py @@ -54,7 +54,6 @@ def save_snapshot( if not os.path.exists(file_dir): logging.debug(f"{file_dir} doesn't exist, creating...") os.makedirs(file_dir) - return False file = f"{file_dir}/{file_name}"