Changes
This commit is contained in:
+11
-5
@@ -473,8 +473,6 @@ pub mod cov_db {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub mod endpoint {
|
pub mod endpoint {
|
||||||
use std::io::Write;
|
|
||||||
|
|
||||||
use axum::response::IntoResponse;
|
use axum::response::IntoResponse;
|
||||||
|
|
||||||
/// Endpoint to queue cover art
|
/// Endpoint to queue cover art
|
||||||
@@ -714,9 +712,8 @@ pub mod endpoint {
|
|||||||
coverart.title = song.album.clone();
|
coverart.title = song.album.clone();
|
||||||
coverart.data = data;
|
coverart.data = data;
|
||||||
|
|
||||||
let mut file = std::fs::File::create(&save_path).unwrap();
|
match coverart.save_to_filesystem() {
|
||||||
file.write_all(&coverart.data).unwrap();
|
Ok(_) => {
|
||||||
|
|
||||||
match super::cov_db::create(&pool, &coverart, &song.id).await {
|
match super::cov_db::create(&pool, &coverart, &song.id).await {
|
||||||
Ok(id) => {
|
Ok(id) => {
|
||||||
// TODO: Populate song_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) => {
|
Err(err) => {
|
||||||
response.message = err.to_string();
|
response.message = err.to_string();
|
||||||
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
|
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
|
||||||
|
|||||||
+1
-44
@@ -1230,37 +1230,6 @@ pub mod endpoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
match song.save_to_filesystem() {
|
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(_) => match super::song_db::insert(&pool, &song).await {
|
||||||
Ok((date_created, id)) => {
|
Ok((date_created, id)) => {
|
||||||
song.id = id;
|
song.id = id;
|
||||||
@@ -1271,30 +1240,18 @@ pub mod endpoint {
|
|||||||
(axum::http::StatusCode::OK, axum::Json(response))
|
(axum::http::StatusCode::OK, axum::Json(response))
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
response.message =
|
response.message = format!("{:?} song {:?}", err.to_string(), song);
|
||||||
format!("{:?} song {:?}", err.to_string(), song);
|
|
||||||
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
|
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
response.message = err.to_string();
|
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::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
axum::Json(response),
|
axum::Json(response),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
response.message = err.to_string();
|
response.message = err.to_string();
|
||||||
|
|||||||
Reference in New Issue
Block a user