Remove RwLock for database
All checks were successful
/ check_lfs (pull_request) Successful in 9s
/ lint_fmt (pull_request) Successful in 10s
/ lint_clippy (pull_request) Successful in 30s
/ build (pull_request) Successful in 1m19s

This commit is contained in:
Roman Moisieiev 2025-09-11 12:54:54 +01:00
parent d8f785b0db
commit 062f826d28
15 changed files with 39 additions and 64 deletions

View file

@ -21,11 +21,10 @@ pub mod link {
use serenity::all::{CommandDataOption, CommandDataOptionValue, CommandInteraction};
pub async fn run(command: &CommandInteraction, ctx: &Context) -> String {
let db_lock = {
let db = {
let data_read = ctx.data.read().await;
data_read.get::<DataBase>().expect("Expected Databse in TypeMap.").clone()
};
let db = db_lock.read().await;
let config_lock = {
let data_read = ctx.data.read().await;
@ -314,11 +313,10 @@ pub mod verify {
use sqlx::Error;
pub async fn run(command: &CommandInteraction, ctx: &Context) -> String {
let db_lock = {
let db = {
let data_read = ctx.data.read().await;
data_read.get::<DataBase>().expect("Expected Database in TypeMap.").clone()
};
let db = db_lock.read().await;
// check if user has used /link_wolves
let details = if let Some(x) = get_verify_from_db(&db, &command.user.id).await {
@ -494,11 +492,10 @@ pub mod unlink {
use sqlx::{Pool, Sqlite};
pub async fn run(command: &CommandInteraction, ctx: &Context) -> String {
let db_lock = {
let db = {
let data_read = ctx.data.read().await;
data_read.get::<DataBase>().expect("Expected Databse in TypeMap.").clone()
};
let db = db_lock.read().await;
// doesn't matter if there is one or not, it will be removed regardless
delete_link(&db, &command.user.id).await;