From dc6fd622eee8b48fe50eba01567808e588f8e39d Mon Sep 17 00:00:00 2001 From: phoenix Date: Tue, 15 Jul 2025 16:00:18 -0400 Subject: [PATCH 1/4] Added functionality to wipe data from coverart_queue --- src/main.rs | 13 ++++++++++--- src/the_rest.rs | 23 +++++++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 226db68..1173077 100644 --- a/src/main.rs +++ b/src/main.rs @@ -73,9 +73,16 @@ async fn wipe_data_from_queues( .json::() .await { - Ok(_resp) => { - println!("Wiped data from song queue"); - Ok(()) + Ok(_resp) => match the_rest::wipe_data::coverart_queue::wipe_data(app_base_url, coverart_queue_id).await { + Ok(inner_response) => match inner_response.json::().await { + Ok(_inner_resp) => { + println!("Wiped data from CoverArt queue"); + println!("Resp: {_inner_resp:?}"); + Ok(()) + } + Err(err) => Err(std::io::Error::other(err.to_string())) + } + Err(err) => Err(std::io::Error::other(err.to_string())) } Err(err) => Err(std::io::Error::other(err.to_string())), }, diff --git a/src/the_rest.rs b/src/the_rest.rs index b5fa85f..c806f0f 100644 --- a/src/the_rest.rs +++ b/src/the_rest.rs @@ -99,4 +99,27 @@ pub mod wipe_data { } } // TODO: Wipe data from queued coverart + pub mod coverart_queue { + pub async fn wipe_data( + base_url: &String, + coverart_queue_id: &uuid::Uuid, + ) -> Result { + let client = reqwest::Client::builder().build()?; + let url = format!("{base_url}/api/v2/coverart/queue/data/wipe"); + let payload = serde_json::json!({ + "coverart_queue_id": coverart_queue_id + }); + let request = client.patch(url).json(&payload); + + request.send().await + } + + pub mod response { + #[derive(Debug, serde::Deserialize, serde::Serialize)] + pub struct Response { + pub message: String, + pub data: Vec, + } + } + } } -- 2.43.0 From 65916aec71a72932c3874b39c70af926f49cf8ed Mon Sep 17 00:00:00 2001 From: phoenix Date: Tue, 15 Jul 2025 16:01:22 -0400 Subject: [PATCH 2/4] Cleanup --- src/main.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1173077..17f1cf9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,8 +25,8 @@ async fn main() -> Result<(), Box> { // TODO: Do something with the result later match some_work(&app_base_url, &song_queue_id).await { Ok(( - song, - coverart, + _song, + _coverart, (song_queue_id, song_queue_path), (coverart_queue_id, coverart_queue_path), )) => { @@ -38,12 +38,13 @@ async fn main() -> Result<(), Box> { ) .await { - Ok(_) => {} + Ok(_) => { + // TODO: Cleanup files in local filesystem + } Err(err) => { eprintln!("Error: {err:?}"); } } - // TODO: Cleanup files in local filesystem } Err(err) => { eprintln!("Error: {err:?}"); -- 2.43.0 From 2e6ff9cd87774f46e8aee833a613efbb301043a4 Mon Sep 17 00:00:00 2001 From: phoenix Date: Tue, 15 Jul 2025 16:01:36 -0400 Subject: [PATCH 3/4] Code cleanup --- src/main.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 17f1cf9..d2907db 100644 --- a/src/main.rs +++ b/src/main.rs @@ -74,17 +74,25 @@ async fn wipe_data_from_queues( .json::() .await { - Ok(_resp) => match the_rest::wipe_data::coverart_queue::wipe_data(app_base_url, coverart_queue_id).await { - Ok(inner_response) => match inner_response.json::().await { + Ok(_resp) => match the_rest::wipe_data::coverart_queue::wipe_data( + app_base_url, + coverart_queue_id, + ) + .await + { + Ok(inner_response) => match inner_response + .json::() + .await + { Ok(_inner_resp) => { println!("Wiped data from CoverArt queue"); println!("Resp: {_inner_resp:?}"); Ok(()) } - Err(err) => Err(std::io::Error::other(err.to_string())) - } - Err(err) => Err(std::io::Error::other(err.to_string())) - } + Err(err) => Err(std::io::Error::other(err.to_string())), + }, + Err(err) => Err(std::io::Error::other(err.to_string())), + }, Err(err) => Err(std::io::Error::other(err.to_string())), }, Err(err) => Err(std::io::Error::other(err.to_string())), -- 2.43.0 From fbb0b9a8b1dc20acaf4710680709e164d9d46efa Mon Sep 17 00:00:00 2001 From: phoenix Date: Tue, 15 Jul 2025 16:04:54 -0400 Subject: [PATCH 4/4] Version bump --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dab90be..5f7e8b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1255,7 +1255,7 @@ dependencies = [ [[package]] name = "songparser" -version = "0.2.2" +version = "0.2.3" dependencies = [ "futures", "icarus_envy", diff --git a/Cargo.toml b/Cargo.toml index 97dae28..0861cc9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "songparser" -version = "0.2.2" +version = "0.2.3" edition = "2024" rust-version = "1.88" -- 2.43.0