Adding code for saving to bucket
pr CI / Test Suite (pull_request) Failing after 2m50s

This commit is contained in:
2026-08-14 09:33:57 -04:00
parent c88c8fe74b
commit ffe293d955
2 changed files with 54 additions and 4 deletions
+38 -1
View File
@@ -137,6 +137,7 @@ 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();
@@ -159,8 +160,43 @@ pub mod endpoint {
}
}
song.file_key = format!("processed/song/{}", song.filename);
let data_of_song = labyrinth::Data {
raw_data: song.data.clone(),
..Default::default()
};
match lr.upload(&song.file_key, &data_of_song).await {
Ok(_resp) => {
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) => {
eprintln!("Error: {err:?}");
(
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
axum::Json(response),
)
}
}
/*
match song.save_to_filesystem() {
Ok(_) => match repo::song::insert(&pool, &song).await {
Ok(_) =>
match repo::song::insert(&pool, &song).await {
Ok((date_created, id)) => {
song.id = id;
song.date_created = Some(date_created);
@@ -183,6 +219,7 @@ pub mod endpoint {
)
}
}
*/
}
Err(err) => {
eprintln!("Error: {err:?}");
+16 -3
View File
@@ -6,8 +6,8 @@ pub async fn insert(
) -> Result<(time::OffsetDateTime, uuid::Uuid), sqlx::Error> {
let result = sqlx::query(
r#"
INSERT INTO "song" (title, artist, album_artist, album, genre, year, track, disc, track_count, disc_count, duration, audio_type, filename, directory, user_id)
VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15) RETURNING date_created, id;
INSERT INTO "song" (title, artist, album_artist, album, genre, year, track, disc, track_count, disc_count, duration, audio_type, filename, directory, file_key, user_id)
VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16) RETURNING date_created, id;
"#
)
.bind(&song.title)
@@ -24,6 +24,7 @@ pub async fn insert(
.bind(&song.audio_type)
.bind(&song.filename)
.bind(&song.directory)
.bind(&song.file_key)
.bind(song.user_id)
.fetch_one(pool)
.await
@@ -133,6 +134,10 @@ pub async fn get_song(
.try_get("directory")
.map_err(|_e| sqlx::Error::RowNotFound)
.unwrap(),
file_key: row
.try_get("file_key")
.map_err(|_e| sqlx::Error::RowNotFound)
.unwrap(),
date_created: Some(date_created_time),
user_id: row
.try_get("user_id")
@@ -228,6 +233,10 @@ pub async fn get_all_songs(pool: &sqlx::PgPool) -> Result<Vec<simodels::song::So
.try_get("directory")
.map_err(|_e| sqlx::Error::RowNotFound)
.unwrap(),
file_key: row
.try_get("file_key")
.map_err(|_e| sqlx::Error::RowNotFound)
.unwrap(),
date_created: Some(date_created_time),
user_id: row
.try_get("user_id")
@@ -254,7 +263,7 @@ pub async fn delete_song(
r#"
DELETE FROM "song"
WHERE id = $1
RETURNING id, title, artist, album, album_artist, genre, year, disc, track, track_count, disc_count, duration, audio_type, date_created, filename, directory, user_id
RETURNING id, title, artist, album, album_artist, genre, year, disc, track, track_count, disc_count, duration, audio_type, date_created, filename, directory, file_key, user_id
"#,
)
.bind(id)
@@ -332,6 +341,10 @@ pub async fn delete_song(
.try_get("directory")
.map_err(|_e| sqlx::Error::RowNotFound)
.unwrap(),
file_key: row
.try_get("file_key")
.map_err(|_e| sqlx::Error::RowNotFound)
.unwrap(),
date_created: Some(date_created_time),
user_id: row
.try_get("user_id")