This commit is contained in:
kdeng00
2025-10-11 19:45:41 -04:00
parent 0b636d5557
commit a4ca9e212a
2 changed files with 33 additions and 70 deletions
+11 -5
View File
@@ -473,8 +473,6 @@ pub mod cov_db {
}
pub mod endpoint {
use std::io::Write;
use axum::response::IntoResponse;
/// Endpoint to queue cover art
@@ -714,9 +712,8 @@ pub mod endpoint {
coverart.title = song.album.clone();
coverart.data = data;
let mut file = std::fs::File::create(&save_path).unwrap();
file.write_all(&coverart.data).unwrap();
match coverart.save_to_filesystem() {
Ok(_) => {
match super::cov_db::create(&pool, &coverart, &song.id).await {
Ok(id) => {
// TODO: Populate song_id
@@ -734,6 +731,15 @@ pub mod endpoint {
}
}
}
Err(err) => {
response.message = err.to_string();
(
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
axum::Json(response),
)
}
}
}
Err(err) => {
response.message = err.to_string();
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
+1 -44
View File
@@ -1230,37 +1230,6 @@ pub mod endpoint {
}
match song.save_to_filesystem() {
Ok(_) => {
match super::song_db::insert(&pool, &song).await {
Ok((date_created, id)) => {
song.id = id;
song.date_created = date_created;
response.message = String::from("Successful");
response.data.push(song);
(axum::http::StatusCode::OK, axum::Json(response))
}
Err(err) => {
response.message =
format!("{:?} song {:?}", err.to_string(), song);
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
}
}
}
Err(err) => {
response.message = err.to_string();
(axum::http::StatusCode::INTERNAL_SERVER_ERROR, axum::Json(response))
}
}
// let save_path = dir.join(&song.filename);
/*
match std::fs::File::create(&save_path) {
Ok(mut file) => {
file.write_all(&song.data).unwrap();
match song.song_path() {
Ok(_) => match super::song_db::insert(&pool, &song).await {
Ok((date_created, id)) => {
song.id = id;
@@ -1271,30 +1240,18 @@ pub mod endpoint {
(axum::http::StatusCode::OK, axum::Json(response))
}
Err(err) => {
response.message =
format!("{:?} song {:?}", err.to_string(), song);
response.message = format!("{:?} song {:?}", err.to_string(), song);
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
}
},
Err(err) => {
response.message = err.to_string();
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
}
}
}
Err(err) => {
let song_path = song.song_path();
response.message = format!(
"{err:?} Song directory: {} Filename: {} Save Path: {:?} Song Path: {:?}",
song.directory, song.filename, save_path, song_path
);
(
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
axum::Json(response),
)
}
}
*/
}
Err(err) => {
response.message = err.to_string();