Fix error when crypto dependencies aren't installed
This commit is contained in:
parent
5201cb0316
commit
744d370f0b
1 changed files with 15 additions and 13 deletions
|
@ -82,14 +82,15 @@ class Maubot(Program):
|
||||||
)
|
)
|
||||||
init_db(self.db)
|
init_db(self.db)
|
||||||
|
|
||||||
if self.config["crypto_database"] == "default":
|
if PgCryptoStore:
|
||||||
self.crypto_db = self.db
|
if self.config["crypto_database"] == "default":
|
||||||
else:
|
self.crypto_db = self.db
|
||||||
self.crypto_db = Database.create(
|
else:
|
||||||
self.config["crypto_database"],
|
self.crypto_db = Database.create(
|
||||||
upgrade_table=PgCryptoStore.upgrade_table,
|
self.config["crypto_database"],
|
||||||
ignore_foreign_tables=self.args.ignore_foreign_tables,
|
upgrade_table=PgCryptoStore.upgrade_table,
|
||||||
)
|
ignore_foreign_tables=self.args.ignore_foreign_tables,
|
||||||
|
)
|
||||||
|
|
||||||
if self.config["plugin_databases.postgres"] == "default":
|
if self.config["plugin_databases.postgres"] == "default":
|
||||||
if self.db.scheme != Scheme.POSTGRES:
|
if self.db.scheme != Scheme.POSTGRES:
|
||||||
|
@ -135,16 +136,17 @@ class Maubot(Program):
|
||||||
ignore_unsupported = self.args.ignore_unsupported_database
|
ignore_unsupported = self.args.ignore_unsupported_database
|
||||||
self.db.upgrade_table.allow_unsupported = ignore_unsupported
|
self.db.upgrade_table.allow_unsupported = ignore_unsupported
|
||||||
self.state_store.upgrade_table.allow_unsupported = ignore_unsupported
|
self.state_store.upgrade_table.allow_unsupported = ignore_unsupported
|
||||||
PgCryptoStore.upgrade_table.allow_unsupported = ignore_unsupported
|
|
||||||
try:
|
try:
|
||||||
await self.db.start()
|
await self.db.start()
|
||||||
await self.state_store.upgrade_table.upgrade(self.db)
|
await self.state_store.upgrade_table.upgrade(self.db)
|
||||||
if self.plugin_postgres_db and self.plugin_postgres_db is not self.db:
|
if self.plugin_postgres_db and self.plugin_postgres_db is not self.db:
|
||||||
await self.plugin_postgres_db.start()
|
await self.plugin_postgres_db.start()
|
||||||
if self.crypto_db and self.crypto_db is not self.db:
|
if self.crypto_db:
|
||||||
await self.crypto_db.start()
|
PgCryptoStore.upgrade_table.allow_unsupported = ignore_unsupported
|
||||||
else:
|
if self.crypto_db is not self.db:
|
||||||
await PgCryptoStore.upgrade_table.upgrade(self.db)
|
await self.crypto_db.start()
|
||||||
|
else:
|
||||||
|
await PgCryptoStore.upgrade_table.upgrade(self.db)
|
||||||
except DatabaseException as e:
|
except DatabaseException as e:
|
||||||
self.log.critical("Failed to initialize database", exc_info=e)
|
self.log.critical("Failed to initialize database", exc_info=e)
|
||||||
if e.explanation:
|
if e.explanation:
|
||||||
|
|
Loading…
Reference in a new issue