Going
pr CI / Test Suite (pull_request) Successful in 4m26s

This commit is contained in:
2026-08-14 08:15:03 -04:00
parent 85c5672ded
commit 325a3639cc
+80 -28
View File
@@ -63,14 +63,16 @@ pub mod endpoint {
let mut response = super::response::create_coverart::Response::default(); let mut response = super::response::create_coverart::Response::default();
let id = payload.coverart_queue_id; let id = payload.coverart_queue_id;
match repo_queue::coverart::get_coverart_queue_data_with_id(&pool, &id).await { match repo_queue::data::queue::coverart::get_with_coverart_queue_id(&pool, &id).await {
Ok(data) => { Ok((_id, file_key, _bucket, _region, _)) => {
let song_id = payload.song_id; let lab_config = crate::util::maze::get_config();
match crate::repo::song::get_song(&pool, &song_id).await { let lr = labyrinth::Labyrinth { config: lab_config };
Ok(song) => {
let directory = sienvy::environment::get_root_directory().value; match lr.download(&file_key).await {
Ok(data) => {
let file_type = let file_type =
simeta::detection::coverart::file_type_from_data(&data).unwrap(); simeta::detection::coverart::file_type_from_data(&data).unwrap();
let coverart_type = if file_type.file_type let coverart_type = if file_type.file_type
== simeta::detection::coverart::constants::JPEG_TYPE == simeta::detection::coverart::constants::JPEG_TYPE
{ {
@@ -93,34 +95,78 @@ pub mod endpoint {
let filename = let filename =
simodels::coverart::generate_filename(coverart_type, true).unwrap(); simodels::coverart::generate_filename(coverart_type, true).unwrap();
let mut coverart = simodels::coverart::init::init_coverart_dir_and_filename( let data = labyrinth::Data {
&directory, &filename, raw_data: data,
); ..Default::default()
coverart.title = song.album.clone(); };
coverart.file_type = file_type.file_type; let new_file_key = format!("processed/song/{filename}");
coverart.data = data;
match coverart.save_to_filesystem() { match lr.upload(&new_file_key, &data).await {
Ok(_) => { Ok(_resp) => {
match repo::coverart::create(&pool, &coverart, &song.id).await { // TODO: Change it to the s3 bucket
Ok(id) => { let directory = sienvy::environment::get_root_directory().value;
coverart.song_id = song_id; let mut coverart =
coverart.id = id; simodels::coverart::init::init_coverart_dir_and_filename(
println!("Cover Art created"); &directory, &filename,
);
let song = match crate::repo::song::get_song(
&pool,
&payload.song_id,
)
.await
{
Ok(song) => song,
Err(err) => {
eprintln!("Error: {err:?}");
return (
axum::http::StatusCode::BAD_REQUEST,
axum::Json(response),
);
}
};
coverart.title = song.album.clone();
coverart.file_type = file_type.file_type;
coverart.data = data.raw_data;
response.message = String::from("Successful"); match coverart.save_to_filesystem() {
response.data.push(coverart); Ok(_) => {
match repo::coverart::create(
&pool,
&coverart,
&payload.song_id,
)
.await
{
Ok(id) => {
coverart.song_id = payload.song_id;
coverart.id = id;
println!("Cover Art created");
(axum::http::StatusCode::OK, axum::Json(response)) response.message = String::from("Successful");
response.data.push(coverart);
(axum::http::StatusCode::OK, axum::Json(response))
}
Err(err) => {
response.message = err.to_string();
(
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)) (
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
axum::Json(response),
)
} }
} }
} }
Err(err) => { Err(err) => {
response.message = err.to_string(); eprintln!("Error: {err:?}");
( (
axum::http::StatusCode::INTERNAL_SERVER_ERROR, axum::http::StatusCode::INTERNAL_SERVER_ERROR,
axum::Json(response), axum::Json(response),
@@ -129,14 +175,20 @@ pub mod endpoint {
} }
} }
Err(err) => { Err(err) => {
response.message = err.to_string(); eprintln!("Error: {err:?}");
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response)) (
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
axum::Json(response),
)
} }
} }
} }
Err(err) => { Err(err) => {
response.message = err.to_string(); eprintln!("Error: {err:?}");
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response)) (
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
axum::Json(response),
)
} }
} }
} }