Compare commits

..
1 Commits
Author SHA1 Message Date
phoenix 718cdb617d S3 coverart (#261)
soaricarus_api CI / Check (push) Successful in 6m37s
soaricarus_api CI / Rustfmt (push) Successful in 4m19s
soaricarus_api CI / Clippy (push) Successful in 6m57s
soaricarus_api CI / build (push) Successful in 6m58s
soaricarus_api CI / Test Suite (push) Successful in 3m37s
Reviewed-on: #261
2026-08-15 12:30:44 -04:00
4 changed files with 53 additions and 3 deletions
Generated
+1 -1
View File
@@ -3013,7 +3013,7 @@ dependencies = [
[[package]]
name = "soaricarus_api"
version = "0.5.6"
version = "0.5.7"
dependencies = [
"axum",
"axum-extra",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "soaricarus_api"
version = "0.5.6"
version = "0.5.7"
edition = "2024"
rust-version = "1.95"
license = "MIT"
+4 -1
View File
@@ -232,8 +232,11 @@ pub mod endpoint {
axum::Extension(pool): axum::Extension<sqlx::PgPool>,
axum::extract::Path(id): axum::extract::Path<uuid::Uuid>,
) -> (axum::http::StatusCode, axum::response::Response) {
let lab_config = crate::util::maze::get_config();
let lr = labyrinth::Labyrinth { config: lab_config };
match repo::coverart::get_coverart(&pool, &id).await {
Ok(coverart) => match simodels::coverart::io::to_data(&coverart) {
Ok(coverart) => match lr.download(&coverart.file_key).await {
Ok(data) => {
let (file_type, img_type) =
match simeta::detection::coverart::file_type_from_data(&data) {
+47
View File
@@ -503,11 +503,19 @@ mod tests {
pub const TEST_SONG_01_FILE_KEY: &str = "processed/song/track01.flac";
pub const TEST_SONG_02_FILE_KEY: &str = "processed/song/track02.flac";
pub const TEST_COVERART_01_FILE_KEY: &str = "processed/coverart/Coverart-1.jpg";
pub const TEST_COVERART_02_FILE_KEY: &str = "processed/coverart/Coverart-2.jpg";
pub struct SongBucket {
pub file_key: String,
pub path: String,
}
pub struct CoverArtBucket {
pub file_key: String,
pub path: String,
}
pub async fn upload_test_songs_to_bucket() {
let songs = vec![
SongBucket {
@@ -546,6 +554,44 @@ mod tests {
}
}
pub async fn upload_test_coverarts_to_bucket() {
let coverarts = vec![
CoverArtBucket {
file_key: TEST_COVERART_01_FILE_KEY.to_string(),
path: "tests/I/Coverart-1.jpg".to_string(),
},
CoverArtBucket {
file_key: TEST_COVERART_02_FILE_KEY.to_string(),
path: "tests/I/Coverart-2.jpg".to_string(),
},
];
let lab_config = soaricarus_api::util::maze::get_config();
let lr = labyrinth::Labyrinth { config: lab_config };
for coverart in &coverarts {
let p = std::path::Path::new(&coverart.path);
match tokio::fs::File::open(p).await {
Ok(mut _file) => {
let data = labyrinth::Data {
filepath: coverart.path.clone(),
..Default::default()
};
match lr.upload(&coverart.file_key, &data).await {
Ok(_) => {}
Err(err) => {
assert!(false, "Error: {err:?}");
}
}
}
Err(err) => {
assert!(false, "Error: {err:?}");
}
};
}
}
pub async fn delete_test_songs_from_bucket() {
let songs = vec![
SongBucket {
@@ -633,6 +679,7 @@ mod tests {
app: &axum::Router,
song_queue_id: &uuid::Uuid,
) -> Result<axum::response::Response, axum::http::Error> {
upload_test_coverarts_to_bucket().await;
match super::request::upload_coverart_queue_req(&app).await {
Ok(response) => {
let resp = super::util::get_resp_data::<