Don't fail on erroneus db connection closure

This commit is contained in:
2024-08-07 16:16:46 +02:00
parent 460a8d6abb
commit 01d502337d
4 changed files with 25 additions and 15 deletions

View File

@@ -2,6 +2,7 @@ use anyhow::Context;
use indoc::indoc;
use itertools::Itertools;
use nix::unistd::{getuid, Group, User};
use sqlx::{Connection, MySqlConnection};
#[cfg(not(target_os = "macos"))]
use std::ffi::CString;
@@ -140,6 +141,13 @@ pub fn validate_ownership_by_user_prefix<'a>(
Ok(prefix)
}
pub async fn close_database_connection(conn: MySqlConnection) {
if let Err(e) = conn.close().await.context("Failed to close connection properly") {
eprintln!("{}", e);
eprintln!("Ignoring...");
}
}
pub fn quote_literal(s: &str) -> String {
format!("'{}'", s.replace('\'', r"\'"))
}