@@ -182,7 +182,7 @@ pub mod endpoint {
|
||||
|
||||
let lr = labyrinth::Labyrinth { config: lab_config };
|
||||
let data = labyrinth::Data {
|
||||
raw_data: raw_data,
|
||||
raw_data,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
|
||||
+1
-38
@@ -137,19 +137,14 @@ pub mod endpoint {
|
||||
song.filename =
|
||||
simodels::song::generate_filename(simodels::types::MusicType::FlacExtension, true)
|
||||
.unwrap();
|
||||
// Will no longer be needed with s3
|
||||
song.directory = sienvy::environment::get_root_directory().value;
|
||||
|
||||
let lab_config = crate::util::maze::get_config();
|
||||
let lr = labyrinth::Labyrinth { config: lab_config };
|
||||
|
||||
println!("Wut?");
|
||||
|
||||
match repo_queue::data::get_with_song_queue_id(&pool, &payload.song_queue_id).await {
|
||||
Ok((_id, file_key, _bucket, _region, _)) => match lr.download(&file_key).await {
|
||||
Ok(data) => {
|
||||
println!("Okay!");
|
||||
println!("File key: {:?}", file_key);
|
||||
song.data = data;
|
||||
let dir = std::path::Path::new(&song.directory);
|
||||
if !dir.exists() {
|
||||
@@ -165,7 +160,6 @@ pub mod endpoint {
|
||||
}
|
||||
|
||||
song.file_key = format!("processed/song/{}", song.filename);
|
||||
println!("Processed file key: {:?}", song.file_key);
|
||||
let data_of_song = labyrinth::Data {
|
||||
raw_data: song.data.clone(),
|
||||
..Default::default()
|
||||
@@ -182,14 +176,12 @@ pub mod endpoint {
|
||||
(axum::http::StatusCode::OK, axum::Json(response))
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error inserting");
|
||||
response.message =
|
||||
format!("{:?} song {:?}", err.to_string(), song);
|
||||
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
|
||||
}
|
||||
},
|
||||
Err(err) => {
|
||||
eprintln!("Error uploading");
|
||||
eprintln!("Error: {err:?}");
|
||||
(
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
@@ -197,34 +189,6 @@ pub mod endpoint {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
match song.save_to_filesystem() {
|
||||
Ok(_) =>
|
||||
match repo::song::insert(&pool, &song).await {
|
||||
Ok((date_created, id)) => {
|
||||
song.id = id;
|
||||
song.date_created = Some(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),
|
||||
)
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
@@ -343,7 +307,7 @@ pub mod endpoint {
|
||||
true,
|
||||
)
|
||||
.unwrap();
|
||||
// Will no longer be needed with s3
|
||||
// TODO: At some point, directory will no longer be needed with s3
|
||||
song.directory = sienvy::environment::get_root_directory().value;
|
||||
song.data = data;
|
||||
|
||||
@@ -517,7 +481,6 @@ pub mod endpoint {
|
||||
match repo::coverart::delete_coverart(&pool, &coverart.id).await
|
||||
{
|
||||
Ok(deleted_coverart) => {
|
||||
// match song.remove_from_filesystem() {
|
||||
match lr.delete(&song.file_key).await {
|
||||
Ok(_) => match coverart.remove_from_filesystem() {
|
||||
Ok(_) => {
|
||||
|
||||
+4
-27
@@ -500,8 +500,6 @@ 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";
|
||||
|
||||
@@ -511,8 +509,6 @@ mod tests {
|
||||
}
|
||||
|
||||
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(),
|
||||
@@ -524,15 +520,14 @@ mod tests {
|
||||
},
|
||||
];
|
||||
|
||||
let lab_config = soaricarus_api::util::maze::get_config();
|
||||
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()
|
||||
};
|
||||
@@ -543,21 +538,6 @@ mod tests {
|
||||
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:?}");
|
||||
@@ -566,9 +546,7 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn delete_test_songs_to_bucket() {
|
||||
let lab_config = soaricarus_api::util::maze::get_config();
|
||||
|
||||
pub async fn delete_test_songs_from_bucket() {
|
||||
let songs = vec![
|
||||
SongBucket {
|
||||
file_key: TEST_SONG_01_FILE_KEY.to_string(),
|
||||
@@ -580,6 +558,7 @@ mod tests {
|
||||
},
|
||||
];
|
||||
|
||||
let lab_config = soaricarus_api::util::maze::get_config();
|
||||
let lr = labyrinth::Labyrinth { config: lab_config };
|
||||
|
||||
for song in &songs {
|
||||
@@ -715,7 +694,6 @@ 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(),
|
||||
@@ -731,8 +709,6 @@ mod tests {
|
||||
song
|
||||
);
|
||||
|
||||
// eprintln!("Song: {:?}", song);
|
||||
|
||||
match queue_coverart_flow(&app, &song_queue_id).await {
|
||||
Ok(response) => Ok((response, song_queue_id)),
|
||||
Err(err) => {
|
||||
@@ -871,6 +847,7 @@ mod tests {
|
||||
};
|
||||
|
||||
let _ = db_mgr::drop_database(&tm_pool, &db_name).await;
|
||||
sequence_flow::delete_test_songs_from_bucket().await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
Reference in New Issue
Block a user