diff options
author | Azrenbeth <7782548+Azrenbeth@users.noreply.github.com> | 2021-09-27 16:20:06 +0100 |
---|---|---|
committer | Azrenbeth <7782548+Azrenbeth@users.noreply.github.com> | 2021-09-27 16:20:06 +0100 |
commit | efbc338043b2dd560a27285396d1dacb25301ae3 (patch) | |
tree | 0ba27f9df8cdcde6c89307a1dbdb53fd9b4ddcb1 | |
parent | Move from compressing largest rooms to compressing number of chunks (diff) | |
download | synapse-efbc338043b2dd560a27285396d1dacb25301ae3.tar.xz |
Extract password from db_args
-rw-r--r-- | synapse/util/state_compressor.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/synapse/util/state_compressor.py b/synapse/util/state_compressor.py index 2f85fb7ea3..672e6f91c9 100644 --- a/synapse/util/state_compressor.py +++ b/synapse/util/state_compressor.py @@ -57,10 +57,22 @@ def setup_state_compressor(hs: "HomeServer"): return # Check that the database being used is postgres - db_config = hs.config.database.get_single_database().config + if hs.get_datastores().state is not None: + for conf in hs.config.database.databases: + if conf.name == "state": + db_config = conf.config + break + else: + for conf in hs.config.database.databases: + if conf.name == "master": + db_config = conf.config + break + if db_config["name"] != "psycopg2": return + password = db_config.get("args").get("password") + # Construct the database URL from the database config. # # This is a bit convoluted as the rust postgres library doesn't have a @@ -77,6 +89,11 @@ def setup_state_compressor(hs: "HomeServer"): if key in _VALID_POSTGRES_CONN_ARGS: effective_db_args[key] = value + # We cannot extract the password from the connection info, so use the value extracted + # from synapse's config + if password is not None: + effective_db_args["password"] = password + # psycopg2 has a handy util function from going from dictionary to a DSN # (postgres connection string.) from psycopg2.extensions import make_dsn |