From 946ebc350ee0bf0a9fb654c12a0e95569b6d045f Mon Sep 17 00:00:00 2001 From: Axel Hodler Date: Sun, 27 Mar 2022 17:03:24 +0200 Subject: [PATCH] fail early if LNBITS_DATA_FOLDER missing --- lnbits/db.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lnbits/db.py b/lnbits/db.py index 028509584..7bbfa5c55 100644 --- a/lnbits/db.py +++ b/lnbits/db.py @@ -130,9 +130,15 @@ class Database(Compat): ) ) else: - self.path = os.path.join(LNBITS_DATA_FOLDER, f"{self.name}.sqlite3") - database_uri = f"sqlite:///{self.path}" - self.type = SQLITE + if os.path.isdir(LNBITS_DATA_FOLDER): + self.path = os.path.join(LNBITS_DATA_FOLDER, f"{self.name}.sqlite3") + database_uri = f"sqlite:///{self.path}" + self.type = SQLITE + else: + raise NotADirectoryError( + f"LNBITS_DATA_FOLDER named {LNBITS_DATA_FOLDER} was not created" + f" - please 'mkdir {LNBITS_DATA_FOLDER}' and try again" + ) self.schema = self.name if self.name.startswith("ext_"):