Fix error when crypto dependencies aren't installed

This commit is contained in:
Tulir Asokan 2022-03-29 17:40:27 +03:00
parent 5201cb0316
commit 744d370f0b

View File

@ -82,6 +82,7 @@ class Maubot(Program):
) )
init_db(self.db) init_db(self.db)
if PgCryptoStore:
if self.config["crypto_database"] == "default": if self.config["crypto_database"] == "default":
self.crypto_db = self.db self.crypto_db = self.db
else: else:
@ -135,13 +136,14 @@ 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:
PgCryptoStore.upgrade_table.allow_unsupported = ignore_unsupported
if self.crypto_db is not self.db:
await self.crypto_db.start() await self.crypto_db.start()
else: else:
await PgCryptoStore.upgrade_table.upgrade(self.db) await PgCryptoStore.upgrade_table.upgrade(self.db)