diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/database/postgres/mod.rs | 14 | ||||
-rw-r--r-- | src/webmentions/queue.rs | 9 |
2 files changed, 4 insertions, 19 deletions
diff --git a/src/database/postgres/mod.rs b/src/database/postgres/mod.rs index 98d9f8d..af19fea 100644 --- a/src/database/postgres/mod.rs +++ b/src/database/postgres/mod.rs @@ -48,21 +48,11 @@ impl PostgresStorage { impl Storage for PostgresStorage { /// Construct a new [`PostgresStorage`] from an URI string and run /// migrations on the database. - /// - /// If `PGPASS_FILE` environment variable is defined, read the - /// password from the file at the specified path. If, instead, - /// the `PGPASS` environment variable is present, read the - /// password from it. async fn new(url: &'_ url::Url) -> Result<Self> { tracing::debug!("Postgres URL: {url}"); - let mut options = sqlx::postgres::PgConnectOptions::from_url(url)? + let options = sqlx::postgres::PgConnectOptions::from_url(url)? .options([("search_path", "kittybox")]); - if let Ok(password_file) = std::env::var("PGPASS_FILE") { - let password = tokio::fs::read_to_string(password_file).await.unwrap(); - options = options.password(&password); - } else if let Ok(password) = std::env::var("PGPASS") { - options = options.password(&password) - } + Self::from_pool( sqlx::postgres::PgPoolOptions::new() .max_connections(50) diff --git a/src/webmentions/queue.rs b/src/webmentions/queue.rs index dfa2a48..52bcdfa 100644 --- a/src/webmentions/queue.rs +++ b/src/webmentions/queue.rs @@ -113,14 +113,9 @@ impl<T> Clone for PostgresJobQueue<T> { impl PostgresJobQueue<Webmention> { pub async fn new(uri: &url::Url) -> Result<Self, sqlx::Error> { - let mut options = sqlx::postgres::PgConnectOptions::from_url(uri)? + let options = sqlx::postgres::PgConnectOptions::from_url(uri)? .options([("search_path", "kittybox_webmention")]); - if let Ok(password_file) = std::env::var("PGPASS_FILE") { - let password = tokio::fs::read_to_string(password_file).await.unwrap(); - options = options.password(&password); - } else if let Ok(password) = std::env::var("PGPASS") { - options = options.password(&password) - } + Self::from_pool( sqlx::postgres::PgPoolOptions::new() .max_connections(50) |