Merge pull request #575 from axelhodler/exception_handling

fail early if LNBITS_DATA_FOLDER missing
This commit is contained in:
Arc 2022-03-30 12:04:28 +01:00 committed by GitHub
commit 54264315f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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_"):