From 5898e5ab4359945ef52dc7460bb2937a85603fc2 Mon Sep 17 00:00:00 2001 From: niliara-edu Date: Sun, 26 Jan 2025 12:25:13 +0100 Subject: authentication done --- src/database/album.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/database/album.rs') diff --git a/src/database/album.rs b/src/database/album.rs index 87054f1..d7ffae0 100644 --- a/src/database/album.rs +++ b/src/database/album.rs @@ -114,18 +114,22 @@ impl DatabaseWrapper { } pub async fn edit_album(&self, data: AlbumPut) -> Result { - if data.id.is_none() { return Err(sqlx::Error::RowNotFound); } + if data.id.is_none() { + return Err(sqlx::Error::RowNotFound); + } let og_album: Album = match self.select_album_by_id(data.id.as_ref().unwrap()).await { Ok(res) => match res.is_some() { true => res.unwrap(), false => return Err(sqlx::Error::RowNotFound), - } + }, Err(_) => return Err(sqlx::Error::RowNotFound), }; sqlx::query!( "UPDATE album SET name=?, cover=? WHERE id=?", - data.name.unwrap_or(og_album.name.unwrap_or(String::default())), - data.cover.unwrap_or(og_album.cover.unwrap_or(String::default())), + data.name + .unwrap_or(og_album.name.unwrap_or(String::default())), + data.cover + .unwrap_or(og_album.cover.unwrap_or(String::default())), data.id, ) .execute(&self.db_pool) @@ -149,5 +153,4 @@ impl DatabaseWrapper { .execute(&self.db_pool) .await } - } -- cgit v1.2.3