S3 song download #260

Merged
phoenix merged 15 commits from s3-song_download into main 2026-08-14 16:41:57 -04:00
2 changed files with 105 additions and 5 deletions
Showing only changes of commit aea8b14e14 - Show all commits
+96 -1
View File
@@ -500,10 +500,103 @@ mod tests {
}
mod sequence_flow {
use std::io::Read;
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 struct SongBucket {
pub file_key: String,
pub path: String,
}
pub async fn upload_test_songs_to_bucket() {
let lab_config = soaricarus_api::util::maze::get_config();
let songs = vec![
SongBucket {
file_key: TEST_SONG_01_FILE_KEY.to_string(),
path: "tests/I/track01.flac".to_string(),
},
SongBucket {
file_key: TEST_SONG_02_FILE_KEY.to_string(),
path: "tests/I/track02.flac".to_string(),
},
];
let lr = labyrinth::Labyrinth { config: lab_config };
for song in &songs {
let p = std::path::Path::new(&song.path);
// match std::fs::File::open(p) {
match tokio::fs::File::open(p).await {
Ok(mut _file) => {
let data = labyrinth::Data {
// raw_data: buffer,
filepath: song.path.clone(),
..Default::default()
};
match lr.upload(&song.file_key, &data).await {
Ok(_) => {}
Err(err) => {
assert!(false, "Error: {err:?}");
}
}
/*
let mut buffer: Vec<u8> = Vec::new();
match file.read_to_end(&mut buffer) {
Ok(_) => {
if buffer.is_empty() {
} else {
}
}
Err(err) => {
assert!(false, "Error: {err:?}");
}
}
*/
}
Err(err) => {
assert!(false, "Error: {err:?}");
}
};
}
}
pub async fn delete_test_songs_to_bucket() {
let lab_config = soaricarus_api::util::maze::get_config();
let songs = vec![
SongBucket {
file_key: TEST_SONG_01_FILE_KEY.to_string(),
path: "tests/I/track01.flac".to_string(),
},
SongBucket {
file_key: TEST_SONG_02_FILE_KEY.to_string(),
path: "tests/I/track02.flac".to_string(),
},
];
let lr = labyrinth::Labyrinth { config: lab_config };
for song in &songs {
match lr.delete(&song.file_key).await {
Ok(_) => {}
Err(err) => {
assert!(false, "Error: {err:?}");
}
}
}
}
// Flow for queueing song
pub async fn queue_song_flow(
app: &axum::Router,
) -> Result<(axum::response::Response, uuid::Uuid), axum::http::Error> {
upload_test_songs_to_bucket().await;
match super::request::song_queue_req(&app).await {
Ok(response) => {
let resp = super::util::get_resp_data::<
@@ -622,6 +715,7 @@ mod tests {
soaricarus_api::callers::song::response::create_metadata::Response,
>(response)
.await;
assert_eq!(false, resp.data.is_empty(), "Node");
assert_eq!(
false,
resp.data.is_empty(),
@@ -637,7 +731,7 @@ mod tests {
song
);
eprintln!("Song: {:?}", song);
// eprintln!("Song: {:?}", song);
match queue_coverart_flow(&app, &song_queue_id).await {
Ok(response) => Ok((response, song_queue_id)),
@@ -1111,6 +1205,7 @@ mod tests {
match sequence_flow::queue_song_and_coverart_flow(&app).await {
Ok((resp_one, song_queue_id)) => {
assert!(false, "Got here 2");
let resp = util::get_resp_data::<
soaricarus_api::callers::queue::coverart::response::fetch_coverart_no_data::Response,
>(resp_one)
@@ -1,6 +1,11 @@
-- Add migration script here
INSERT INTO "song" (id, title, artist, album_artist, album, genre, year, track, disc, track_count, disc_count, duration, audio_type, date_created, filename, directory, user_id) VALUES('44cf7940-34ff-489f-9124-d0ec90a55af9', 'Hypocrite Like The Rest', 'Kuoth', 'Kuoth', 'I', 'Alternative Hip-Hop', 2020, 1, 1, 9, 1, 139, 'flac', '2020-01-01 13:00:00-05', 'track01.flac', 'tests/I', '47491f9b-725a-4ba4-b9a5-711e1be46670');
INSERT INTO "coverart" (id, title, directory, filename, file_type, song_id) VALUES('996122cd-5ae9-4013-9934-60768d3006ed', 'I', 'tests/I', 'Coverart-1.jpg', 'jpeg', '44cf7940-34ff-489f-9124-d0ec90a55af9');
INSERT INTO "song" (id, title, artist, album_artist, album, genre, year, track, disc, track_count, disc_count, duration, audio_type, date_created, filename, directory, file_key, user_id)
VALUES('44cf7940-34ff-489f-9124-d0ec90a55af9', 'Hypocrite Like The Rest', 'Kuoth', 'Kuoth', 'I', 'Alternative Hip-Hop', 2020, 1, 1, 9, 1, 139, 'flac', '2020-01-01 13:00:00-05', 'track01.flac', 'tests/I', 'processed/song/track01.flac', '47491f9b-725a-4ba4-b9a5-711e1be46670');
INSERT INTO "song" (id, title, artist, album_artist, album, genre, year, track, disc, track_count, disc_count, duration, audio_type, date_created, filename, directory, user_id) VALUES('94cf7940-34ff-489f-9124-d0ec90a55af4', 'It''s Too Late', 'Kuoth', 'Kuoth', 'I', 'Alternative Hip-Hop', 2020, 2, 1, 9, 1, 116, 'flac', '2020-01-01 13:01:00-05', 'track02.flac', 'tests/I', '47491f9b-725a-4ba4-b9a5-711e1be46670');
INSERT INTO "coverart" (id, title, directory, filename, file_type, song_id) VALUES('d96122cd-5ae9-4013-9934-60768d3006e9', 'I', 'tests/I', 'Coverart-2.jpg', 'jpeg', '94cf7940-34ff-489f-9124-d0ec90a55af4');
INSERT INTO "coverart" (id, title, directory, filename, file_type, song_id)
VALUES('996122cd-5ae9-4013-9934-60768d3006ed', 'I', 'tests/I', 'Coverart-1.jpg', 'jpeg', '44cf7940-34ff-489f-9124-d0ec90a55af9');
INSERT INTO "song" (id, title, artist, album_artist, album, genre, year, track, disc, track_count, disc_count, duration, audio_type, date_created, filename, directory, file_key, user_id)
VALUES('94cf7940-34ff-489f-9124-d0ec90a55af4', 'It''s Too Late', 'Kuoth', 'Kuoth', 'I', 'Alternative Hip-Hop', 2020, 2, 1, 9, 1, 116, 'flac', '2020-01-01 13:01:00-05', 'track02.flac', 'tests/I', 'processed/song/track02.flac', '47491f9b-725a-4ba4-b9a5-711e1be46670');
INSERT INTO "coverart" (id, title, directory, filename, file_type, song_id)
VALUES('d96122cd-5ae9-4013-9934-60768d3006e9', 'I', 'tests/I', 'Coverart-2.jpg', 'jpeg', '94cf7940-34ff-489f-9124-d0ec90a55af4');