Compare commits
10
Commits
main
..
d2d0a7c394
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d2d0a7c394
|
||
|
|
9a6985873c
|
||
|
|
919803a2cc
|
||
|
|
7478f353ce
|
||
|
|
6955c781c3
|
||
|
|
3cd5817a14
|
||
|
|
8e40744859
|
||
|
|
f235073641
|
||
|
|
5a4ba40064
|
||
|
|
0f1c3bb70f
|
Generated
+236
-249
File diff suppressed because it is too large
Load Diff
+12
-12
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "soaricarus_api"
|
||||
version = "0.5.7"
|
||||
version = "0.5.3"
|
||||
edition = "2024"
|
||||
rust-version = "1.95"
|
||||
license = "MIT"
|
||||
@@ -10,26 +10,26 @@ description = "Core API for interacting with soaricarus"
|
||||
axum = { version = "0.8.9", features = ["multipart"] }
|
||||
axum-extra = { version = "0.12.6", features = ["cookie"] }
|
||||
openssl = { version = "0.10.81", features = ["vendored"] }
|
||||
serde = { version = "1.0.229", features = ["derive"] }
|
||||
serde_json = { version = "1.0.151" }
|
||||
tokio = { version = "1.53.1", features = ["full"] }
|
||||
tokio-util = { version = "0.7.19", features = ["io"] }
|
||||
serde = { version = "1.0.228", features = ["derive"] }
|
||||
serde_json = { version = "1.0.150" }
|
||||
tokio = { version = "1.52.3", features = ["full"] }
|
||||
tokio-util = { version = "0.7.18", features = ["io"] }
|
||||
tower = { version = "0.5.3", features = ["full"] }
|
||||
tower-http = { version = "0.7.0", features = ["cors", "timeout"] }
|
||||
tracing-subscriber = "0.3.23"
|
||||
futures = { version = "0.3.34" }
|
||||
futures = { version = "0.3.32" }
|
||||
mime_guess = { version = "2.0.5" }
|
||||
uuid = { version = "1.24.1", features = ["v4", "serde"] }
|
||||
uuid = { version = "1.23.5", features = ["v4", "serde"] }
|
||||
sqlx = { version = "0.9.0", features = ["postgres", "runtime-tokio", "tls-native-tls", "time", "uuid"] }
|
||||
time = { version = "0.3.55", features = ["formatting", "macros", "parsing", "serde"] }
|
||||
time = { version = "0.3.53", features = ["formatting", "macros", "parsing", "serde"] }
|
||||
jsonwebtoken = { version = "10.3.0", features = ["rust_crypto"] }
|
||||
josekit = { version = "0.10.3" }
|
||||
utoipa = { version = "5.5.0", features = ["axum_extras"] }
|
||||
utoipa-swagger-ui = { version = "9.0.2", features = ["axum"] }
|
||||
simeta = { git = "ssh://git@git.kundeng.us/phoenix/simeta.git", tag = "v0.6.2" }
|
||||
simodels = { git = "ssh://git@git.kundeng.us/phoenix/simodels.git", tag = "v0.11.5-main-94d97cb81d-111" }
|
||||
sienvy = { git = "ssh://git@git.kundeng.us/phoenix/sienvy.git", tag = "v0.8.1" }
|
||||
labyrinth = { git = "ssh://git@git.kundeng.us/phoenix/labyrinth.git", tag = "v0.0.5" }
|
||||
simeta = { git = "ssh://git@git.kundeng.us/phoenix/simeta.git", tag = "v0.6.1-main-b690995806-680" }
|
||||
simodels = { git = "ssh://git@git.kundeng.us/phoenix/simodels.git", tag = "v0.11.3-main-fe9d101bd0-111" }
|
||||
sienvy = { git = "ssh://git@git.kundeng.us/phoenix/sienvy.git", tag = "v0.8.0-main-d06c8fdf49-006" }
|
||||
labyrinth = { git = "ssh://git@git.kundeng.us/phoenix/labyrinth.git", tag = "v0.0.3-3-f99a77ece0-928" }
|
||||
|
||||
[dev-dependencies]
|
||||
common-multipart-rfc7578 = { version = "0.7.0" }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Kun Deng
|
||||
Copyright (c) 2025 Kun Deng
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -6,17 +6,10 @@ CREATE TABLE IF NOT EXISTS "songQueue" (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
filename TEXT NOT NULL,
|
||||
status TEXT CHECK (status IN ('pending', 'ready', 'processing', 'done')),
|
||||
data BYTEA NULL,
|
||||
user_id UUID NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "songQueueData" (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
file_key TEXT NOT NULL,
|
||||
bucket TEXT NOT NULL,
|
||||
region TEXT NOT NULL,
|
||||
song_queue_id UUID NOT NULL
|
||||
);
|
||||
|
||||
-- Table to store queued metadata
|
||||
CREATE TABLE IF NOT EXISTS "metadataQueue" (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
@@ -28,18 +21,11 @@ CREATE TABLE IF NOT EXISTS "metadataQueue" (
|
||||
-- Table to store queued coverart
|
||||
CREATE TABLE IF NOT EXISTS "coverartQueue" (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
data BYTEA NULL,
|
||||
file_type TEXT NOT NULL,
|
||||
song_queue_id UUID NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "coverartQueueData" (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
file_key TEXT NOT NULL,
|
||||
bucket TEXT NOT NULL,
|
||||
region TEXT NOT NULL,
|
||||
coverart_queue_id UUID NOT NULL
|
||||
);
|
||||
|
||||
-- Create an index for better query performance
|
||||
CREATE INDEX metadata_queue_data_metadata ON "metadataQueue" USING gin (metadata);
|
||||
|
||||
@@ -63,7 +49,6 @@ CREATE TABLE IF NOT EXISTS "song" (
|
||||
date_created timestamptz DEFAULT now(),
|
||||
filename TEXT NOT NULL,
|
||||
directory TEXT NOT NULL,
|
||||
file_key TEXT NOT NULL,
|
||||
user_id UUID NULL
|
||||
-- TODO: Add coverart id later. This will allow multiple songs to be linked to a single cover art
|
||||
);
|
||||
@@ -74,6 +59,5 @@ CREATE TABLE IF NOT EXISTS "coverart" (
|
||||
directory TEXT NOT NULL,
|
||||
filename TEXT NOT NULL,
|
||||
file_type TEXT NOT NULL,
|
||||
file_key TEXT NOT NULL,
|
||||
song_id UUID NOT NULL
|
||||
);
|
||||
|
||||
+22
-60
@@ -63,16 +63,14 @@ pub mod endpoint {
|
||||
let mut response = super::response::create_coverart::Response::default();
|
||||
let id = payload.coverart_queue_id;
|
||||
|
||||
match repo_queue::data::queue::coverart::get_with_coverart_queue_id(&pool, &id).await {
|
||||
Ok((_id, file_key, _bucket, _region, _)) => {
|
||||
let lab_config = crate::util::maze::get_config();
|
||||
let lr = labyrinth::Labyrinth { config: lab_config };
|
||||
|
||||
match lr.download(&file_key).await {
|
||||
Ok(data) => {
|
||||
match repo_queue::coverart::get_coverart_queue_data_with_id(&pool, &id).await {
|
||||
Ok(data) => {
|
||||
let song_id = payload.song_id;
|
||||
match crate::repo::song::get_song(&pool, &song_id).await {
|
||||
Ok(song) => {
|
||||
let directory = sienvy::environment::get_root_directory().value;
|
||||
let file_type =
|
||||
simeta::detection::coverart::file_type_from_data(&data).unwrap();
|
||||
|
||||
let coverart_type = if file_type.file_type
|
||||
== simeta::detection::coverart::constants::JPEG_TYPE
|
||||
{
|
||||
@@ -95,45 +93,18 @@ pub mod endpoint {
|
||||
let filename =
|
||||
simodels::coverart::generate_filename(coverart_type, true).unwrap();
|
||||
|
||||
let data = labyrinth::Data {
|
||||
raw_data: data,
|
||||
..Default::default()
|
||||
};
|
||||
let new_file_key = format!("processed/coverart/{filename}");
|
||||
let mut coverart = simodels::coverart::init::init_coverart_dir_and_filename(
|
||||
&directory, &filename,
|
||||
);
|
||||
coverart.title = song.album.clone();
|
||||
coverart.file_type = file_type.file_type;
|
||||
coverart.data = data;
|
||||
|
||||
match lr.upload(&new_file_key, &data).await {
|
||||
Ok(_resp) => {
|
||||
// TODO: Change it to the s3 bucket
|
||||
let directory = sienvy::environment::get_root_directory().value;
|
||||
let mut coverart =
|
||||
simodels::coverart::init::init_coverart_dir_and_filename(
|
||||
&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;
|
||||
coverart.file_key = new_file_key;
|
||||
|
||||
match repo::coverart::create(&pool, &coverart, &payload.song_id)
|
||||
.await
|
||||
{
|
||||
match coverart.save_to_filesystem() {
|
||||
Ok(_) => {
|
||||
match repo::coverart::create(&pool, &coverart, &song.id).await {
|
||||
Ok(id) => {
|
||||
coverart.song_id = payload.song_id;
|
||||
coverart.song_id = song_id;
|
||||
coverart.id = id;
|
||||
println!("Cover Art created");
|
||||
|
||||
@@ -149,7 +120,7 @@ pub mod endpoint {
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
response.message = err.to_string();
|
||||
(
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
axum::Json(response),
|
||||
@@ -158,20 +129,14 @@ pub mod endpoint {
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
(
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
axum::Json(response),
|
||||
)
|
||||
response.message = err.to_string();
|
||||
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
(
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
axum::Json(response),
|
||||
)
|
||||
response.message = err.to_string();
|
||||
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -232,11 +197,8 @@ 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 lr.download(&coverart.file_key).await {
|
||||
Ok(coverart) => match simodels::coverart::io::to_data(&coverart) {
|
||||
Ok(data) => {
|
||||
let (file_type, img_type) =
|
||||
match simeta::detection::coverart::file_type_from_data(&data) {
|
||||
|
||||
+50
-145
@@ -178,60 +178,14 @@ pub mod endpoint {
|
||||
file_type
|
||||
);
|
||||
|
||||
let lab_config = crate::util::maze::get_config();
|
||||
|
||||
let lr = labyrinth::Labyrinth { config: lab_config };
|
||||
let data = labyrinth::Data {
|
||||
raw_data,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let filename = simodels::coverart::generate_filename(
|
||||
simodels::types::CoverArtType::JpegExtension,
|
||||
true,
|
||||
)
|
||||
.unwrap();
|
||||
let file_path = format!("queued/coverart/{filename}");
|
||||
|
||||
println!("Key: {file_path:?}");
|
||||
|
||||
match lr.upload(&file_path, &data).await {
|
||||
Ok(_res) => {
|
||||
match repo::coverart::insert(&pool, &file_type.file_type).await {
|
||||
Ok(id) => {
|
||||
println!("Inserting queued data");
|
||||
match repo::data::queue::coverart::insert(
|
||||
&pool,
|
||||
&file_path,
|
||||
&lr.config.bucket,
|
||||
&lr.config.region,
|
||||
&id,
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_id) => {
|
||||
println!("Successfully did it");
|
||||
response.message = String::from("Successful");
|
||||
response.data.push(id);
|
||||
(axum::http::StatusCode::OK, axum::Json(response))
|
||||
}
|
||||
Err(err) => {
|
||||
response.message = err.to_string();
|
||||
(
|
||||
axum::http::StatusCode::BAD_REQUEST,
|
||||
axum::Json(response),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
response.message = err.to_string();
|
||||
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
|
||||
}
|
||||
}
|
||||
match repo::coverart::insert(&pool, &raw_data, &file_type.file_type).await {
|
||||
Ok(id) => {
|
||||
response.message = String::from("Successful");
|
||||
response.data.push(id);
|
||||
(axum::http::StatusCode::OK, axum::Json(response))
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
response.message = err.to_string();
|
||||
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
|
||||
}
|
||||
}
|
||||
@@ -359,73 +313,47 @@ pub mod endpoint {
|
||||
)]
|
||||
pub async fn fetch_coverart_with_data(
|
||||
axum::Extension(pool): axum::Extension<sqlx::PgPool>,
|
||||
axum::extract::Path(coverart_queue_id): axum::extract::Path<uuid::Uuid>,
|
||||
axum::extract::Path(id): axum::extract::Path<uuid::Uuid>,
|
||||
) -> (axum::http::StatusCode, axum::response::Response) {
|
||||
match repo::data::queue::coverart::get_with_coverart_queue_id(&pool, &coverart_queue_id)
|
||||
.await
|
||||
{
|
||||
Ok((_id, file_key, _bucket, _region, _)) => {
|
||||
let lab_config = crate::util::maze::get_config();
|
||||
let lr = labyrinth::Labyrinth { config: lab_config };
|
||||
match repo::coverart::get_coverart_queue_data_with_id(&pool, &id).await {
|
||||
Ok(data) => {
|
||||
let file_type = simeta::detection::coverart::file_type_from_data(&data).unwrap();
|
||||
let bytes = axum::body::Bytes::from(data);
|
||||
let mut response = bytes.into_response();
|
||||
let headers = response.headers_mut();
|
||||
headers.insert(
|
||||
axum::http::header::CONTENT_TYPE,
|
||||
file_type.mime.parse().unwrap(),
|
||||
);
|
||||
|
||||
match lr.download(&file_key).await {
|
||||
Ok(data) => {
|
||||
let file_type =
|
||||
simeta::detection::coverart::file_type_from_data(&data).unwrap();
|
||||
let bytes = axum::body::Bytes::from(data);
|
||||
let mut response = bytes.into_response();
|
||||
let headers = response.headers_mut();
|
||||
headers.insert(
|
||||
axum::http::header::CONTENT_TYPE,
|
||||
file_type.mime.parse().unwrap(),
|
||||
);
|
||||
let coverart_type = if file_type.file_type
|
||||
== simeta::detection::coverart::constants::JPEG_TYPE
|
||||
{
|
||||
simodels::types::CoverArtType::JpegExtension
|
||||
} else if file_type.file_type == simeta::detection::coverart::constants::JPG_TYPE {
|
||||
simodels::types::CoverArtType::JpgExtension
|
||||
} else if file_type.file_type == simeta::detection::coverart::constants::PNG_TYPE {
|
||||
simodels::types::CoverArtType::PngExtension
|
||||
} else {
|
||||
return (
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
axum::response::Response::default(),
|
||||
);
|
||||
};
|
||||
let filename = simodels::coverart::generate_filename(coverart_type, true).unwrap();
|
||||
headers.insert(
|
||||
axum::http::header::CONTENT_DISPOSITION,
|
||||
format!("attachment; filename=\"{filename}\"")
|
||||
.parse()
|
||||
.unwrap(),
|
||||
);
|
||||
|
||||
let coverart_type = if file_type.file_type
|
||||
== simeta::detection::coverart::constants::JPEG_TYPE
|
||||
{
|
||||
simodels::types::CoverArtType::JpegExtension
|
||||
} else if file_type.file_type
|
||||
== simeta::detection::coverart::constants::JPG_TYPE
|
||||
{
|
||||
simodels::types::CoverArtType::JpgExtension
|
||||
} else if file_type.file_type
|
||||
== simeta::detection::coverart::constants::PNG_TYPE
|
||||
{
|
||||
simodels::types::CoverArtType::PngExtension
|
||||
} else {
|
||||
return (
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
axum::response::Response::default(),
|
||||
);
|
||||
};
|
||||
let filename =
|
||||
simodels::coverart::generate_filename(coverart_type, true).unwrap();
|
||||
headers.insert(
|
||||
axum::http::header::CONTENT_DISPOSITION,
|
||||
format!("attachment; filename=\"{filename}\"")
|
||||
.parse()
|
||||
.unwrap(),
|
||||
);
|
||||
|
||||
(axum::http::StatusCode::OK, response)
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
(
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
axum::response::Response::default(),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Record not found");
|
||||
eprintln!("Error: {err:?}");
|
||||
(
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
axum::response::Response::default(),
|
||||
)
|
||||
(axum::http::StatusCode::OK, response)
|
||||
}
|
||||
Err(_err) => (
|
||||
axum::http::StatusCode::BAD_REQUEST,
|
||||
axum::response::Response::default(),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -455,39 +383,16 @@ pub mod endpoint {
|
||||
let coverart_queue_id = payload.coverart_queue_id;
|
||||
|
||||
match repo::coverart::get_coverart_queue_with_id(&pool, &coverart_queue_id).await {
|
||||
Ok(_coverart_queue) => {
|
||||
match repo::data::queue::coverart::get_with_coverart_queue_id(
|
||||
&pool,
|
||||
&coverart_queue_id,
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok((_id, file_key, _bucket, _region, _)) => {
|
||||
let lab_config = crate::util::maze::get_config();
|
||||
let lr = labyrinth::Labyrinth { config: lab_config };
|
||||
|
||||
match lr.delete(&file_key).await {
|
||||
Ok(_) => {
|
||||
response.message = String::from("Success");
|
||||
response.data.push(coverart_queue_id);
|
||||
|
||||
(axum::http::StatusCode::OK, axum::Json(response))
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
(
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
axum::Json(response),
|
||||
)
|
||||
}
|
||||
}
|
||||
Ok(coverart_queue) => {
|
||||
match repo::coverart::wipe_data(&pool, &coverart_queue.id).await {
|
||||
Ok(id) => {
|
||||
response.message = String::from("Success");
|
||||
response.data.push(id);
|
||||
(axum::http::StatusCode::OK, axum::Json(response))
|
||||
}
|
||||
Err(err) => {
|
||||
response.message = err.to_string();
|
||||
(
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
axum::Json(response),
|
||||
)
|
||||
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+93
-145
@@ -162,6 +162,7 @@ pub mod endpoint {
|
||||
if valid {
|
||||
match repo::song::insert(
|
||||
&pool,
|
||||
&raw_data,
|
||||
&file_name,
|
||||
&crate::repo::queue::song::status::PENDING.to_string(),
|
||||
)
|
||||
@@ -171,33 +172,69 @@ pub mod endpoint {
|
||||
results.push(queued_song);
|
||||
println!("Uploading to bucket");
|
||||
|
||||
let lab_config = crate::util::maze::get_config();
|
||||
let s3_endpoint_url =
|
||||
sienvy::environment::get_env("S3_ENDPOINT_URL");
|
||||
let bucket_name =
|
||||
sienvy::environment::get_env("S3_BUCKET_NAME");
|
||||
let region =
|
||||
sienvy::environment::get_env("GARAGE_S3_REGION");
|
||||
let access_key_id = sienvy::environment::get_env(
|
||||
"GARAGE_DEFAULT_ACCESS_KEY",
|
||||
);
|
||||
let secret_key = sienvy::environment::get_env(
|
||||
"GARAGE_DEFAULT_SECRET_KEY",
|
||||
);
|
||||
|
||||
let lab_config = labyrinth::config::Config {
|
||||
url: s3_endpoint_url.value,
|
||||
bucket: bucket_name.value,
|
||||
region: region.value,
|
||||
access_key_id: access_key_id.value,
|
||||
secret_key: secret_key.value,
|
||||
};
|
||||
|
||||
println!("Labyrinth config: {lab_config:?}");
|
||||
|
||||
let lr = labyrinth::Labyrinth { config: lab_config };
|
||||
let data = labyrinth::Data {
|
||||
raw_data: copied_raw_data,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
println!("Filename: {file_name:?}");
|
||||
let file_path = format!("queued/song/{file_name}");
|
||||
let filename = simodels::song::generate_filename(
|
||||
simodels::types::MusicType::FlacExtension,
|
||||
true,
|
||||
)
|
||||
.unwrap();
|
||||
println!("Filename: {filename:?}");
|
||||
let file_path = format!("queued/song/{filename}");
|
||||
println!("Path: {file_path:?}");
|
||||
|
||||
match lr.upload(&file_path, &data).await {
|
||||
Ok(_res) => {
|
||||
match repo::data::insert(
|
||||
&pool,
|
||||
&file_path,
|
||||
&lr.config.bucket,
|
||||
&lr.config.region,
|
||||
&queued_song,
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_id) => {}
|
||||
Ok(res) => {
|
||||
println!("Result: {res:?}");
|
||||
|
||||
println!("Downloading file");
|
||||
match lr.download(&file_path).await {
|
||||
Ok(res) => {
|
||||
if res.is_empty() {
|
||||
println!("This should not be empty");
|
||||
} else {
|
||||
println!("Size: {:?}", res.len());
|
||||
println!("Going to delete file");
|
||||
|
||||
match lr.delete(&file_path).await {
|
||||
Ok(res) => {
|
||||
println!("Result: {res:?}");
|
||||
println!("Deleted");
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
return (axum::http::StatusCode::INTERNAL_SERVER_ERROR, axum::Json(response));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -342,40 +379,28 @@ pub mod endpoint {
|
||||
)]
|
||||
pub async fn download_queued_song(
|
||||
axum::Extension(pool): axum::Extension<sqlx::PgPool>,
|
||||
axum::extract::Path(song_queue_id): axum::extract::Path<uuid::Uuid>,
|
||||
axum::extract::Path(id): axum::extract::Path<uuid::Uuid>,
|
||||
) -> (axum::http::StatusCode, axum::response::Response) {
|
||||
println!("Id: {song_queue_id}");
|
||||
println!("Id: {id}");
|
||||
|
||||
let lab_config = crate::util::maze::get_config();
|
||||
let lr = labyrinth::Labyrinth { config: lab_config };
|
||||
match repo::song::get_data(&pool, &id).await {
|
||||
Ok(data) => {
|
||||
let by = axum::body::Bytes::from(data);
|
||||
let mut response = by.into_response();
|
||||
let headers = response.headers_mut();
|
||||
headers.insert(
|
||||
axum::http::header::CONTENT_TYPE,
|
||||
"audio/flac".parse().unwrap(),
|
||||
);
|
||||
headers.insert(
|
||||
axum::http::header::CONTENT_DISPOSITION,
|
||||
format!("attachment; filename=\"{id}.flac\"")
|
||||
.parse()
|
||||
.unwrap(),
|
||||
);
|
||||
|
||||
match repo::data::get_with_song_queue_id(&pool, &song_queue_id).await {
|
||||
Ok((id, file_key, _bucket, _region, _)) => match lr.download(&file_key).await {
|
||||
Ok(data) => {
|
||||
let by = axum::body::Bytes::from(data);
|
||||
let mut response = by.into_response();
|
||||
let headers = response.headers_mut();
|
||||
headers.insert(
|
||||
axum::http::header::CONTENT_TYPE,
|
||||
"audio/flac".parse().unwrap(),
|
||||
);
|
||||
headers.insert(
|
||||
axum::http::header::CONTENT_DISPOSITION,
|
||||
format!("attachment; filename=\"{id}.flac\"")
|
||||
.parse()
|
||||
.unwrap(),
|
||||
);
|
||||
|
||||
(axum::http::StatusCode::OK, response)
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
(
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
axum::response::Response::default(),
|
||||
)
|
||||
}
|
||||
},
|
||||
(axum::http::StatusCode::OK, response)
|
||||
}
|
||||
Err(_err) => (
|
||||
axum::http::StatusCode::BAD_REQUEST,
|
||||
axum::response::Response::default(),
|
||||
@@ -463,7 +488,7 @@ pub mod endpoint {
|
||||
)
|
||||
)]
|
||||
pub async fn update_song_queue(
|
||||
axum::extract::Path(song_queue_id): axum::extract::Path<uuid::Uuid>,
|
||||
axum::extract::Path(id): axum::extract::Path<uuid::Uuid>,
|
||||
axum::Extension(pool): axum::Extension<sqlx::PgPool>,
|
||||
mut multipart: axum::extract::Multipart,
|
||||
) -> (
|
||||
@@ -494,75 +519,15 @@ pub mod endpoint {
|
||||
match super::is_song_valid(&raw_data).await {
|
||||
Ok(valid) => {
|
||||
if valid {
|
||||
let lab_config = crate::util::maze::get_config();
|
||||
let lr = labyrinth::Labyrinth { config: lab_config };
|
||||
|
||||
println!("Valid song");
|
||||
|
||||
match repo::data::get_with_song_queue_id(&pool, &song_queue_id).await {
|
||||
Ok((id, file_key, _bucket, _region, _)) => {
|
||||
match lr.delete(&file_key).await {
|
||||
Ok(_response) => {
|
||||
let data = labyrinth::Data {
|
||||
raw_data,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let filename = simodels::song::generate_filename(
|
||||
simodels::types::MusicType::FlacExtension,
|
||||
true,
|
||||
)
|
||||
.unwrap();
|
||||
let new_file_key = format!("queued/song/{filename}");
|
||||
println!("New key: {new_file_key:?}");
|
||||
|
||||
match lr.upload(&new_file_key, &data).await {
|
||||
Ok(_) => {
|
||||
match repo::data::update_file_key(
|
||||
&pool,
|
||||
&id,
|
||||
&new_file_key,
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(_) => {
|
||||
response.message =
|
||||
super::super::super::response::SUCCESSFUL.to_string();
|
||||
response.data.push(song_queue_id);
|
||||
(
|
||||
axum::http::StatusCode::OK,
|
||||
axum::Json(response),
|
||||
)
|
||||
}
|
||||
Err(err) => {
|
||||
response.message = err.to_string();
|
||||
(
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
axum::Json(response),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
(
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
axum::Json(response),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
(
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
axum::Json(response),
|
||||
)
|
||||
}
|
||||
}
|
||||
match repo::song::update(&pool, &raw_data, &id).await {
|
||||
Ok(_) => {
|
||||
response.message =
|
||||
String::from(super::super::super::response::SUCCESSFUL);
|
||||
response.data.push(id);
|
||||
(axum::http::StatusCode::OK, axum::Json(response))
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
response.message = err.to_string();
|
||||
(
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
axum::Json(response),
|
||||
@@ -599,8 +564,7 @@ pub mod endpoint {
|
||||
),
|
||||
responses(
|
||||
(status = 200, description = "Queued song data wiped", body = super::response::wipe_data_from_song_queue::Response),
|
||||
(status = 404, description = "Queued song cannot be found", body = super::response::wipe_data_from_song_queue::Response),
|
||||
(status = 500, description = "Error wiping song data", body = super::response::wipe_data_from_song_queue::Response)
|
||||
(status = 404, description = "Queued song cannot be found", body = super::response::wipe_data_from_song_queue::Response)
|
||||
)
|
||||
)]
|
||||
pub async fn wipe_data_from_song_queue(
|
||||
@@ -611,37 +575,21 @@ pub mod endpoint {
|
||||
axum::Json<super::response::wipe_data_from_song_queue::Response>,
|
||||
) {
|
||||
let mut response = super::response::wipe_data_from_song_queue::Response::default();
|
||||
let song_queue_id = payload.song_queue_id;
|
||||
let id = payload.song_queue_id;
|
||||
|
||||
match repo::song::get_song_queue(&pool, &song_queue_id).await {
|
||||
Ok(_song_queue) => {
|
||||
match repo::data::get_with_song_queue_id(&pool, &song_queue_id).await {
|
||||
Ok((_id, file_key, _bucket, _region, _)) => {
|
||||
let lab_config = crate::util::maze::get_config();
|
||||
let lr = labyrinth::Labyrinth { config: lab_config };
|
||||
match repo::song::get_song_queue(&pool, &id).await {
|
||||
Ok(song_queue) => match repo::song::wipe_data(&pool, &song_queue.id).await {
|
||||
Ok(wiped_id) => {
|
||||
response.message = String::from("Success");
|
||||
response.data.push(wiped_id);
|
||||
|
||||
match lr.delete(&file_key).await {
|
||||
Ok(_) => {
|
||||
response.message = String::from("Success");
|
||||
response.data.push(song_queue_id);
|
||||
|
||||
(axum::http::StatusCode::OK, axum::Json(response))
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
(
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
axum::Json(response),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
response.message = err.to_string();
|
||||
(axum::http::StatusCode::NOT_FOUND, axum::Json(response))
|
||||
}
|
||||
(axum::http::StatusCode::OK, axum::Json(response))
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
response.message = err.to_string();
|
||||
(axum::http::StatusCode::NOT_FOUND, axum::Json(response))
|
||||
}
|
||||
},
|
||||
Err(err) => {
|
||||
response.message = err.to_string();
|
||||
(axum::http::StatusCode::NOT_FOUND, axum::Json(response))
|
||||
|
||||
+69
-140
@@ -139,62 +139,46 @@ pub mod endpoint {
|
||||
.unwrap();
|
||||
song.directory = sienvy::environment::get_root_directory().value;
|
||||
|
||||
let lab_config = crate::util::maze::get_config();
|
||||
let lr = labyrinth::Labyrinth { config: lab_config };
|
||||
|
||||
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) => {
|
||||
song.data = data;
|
||||
let dir = std::path::Path::new(&song.directory);
|
||||
if !dir.exists() {
|
||||
println!("Creating directory");
|
||||
match std::fs::create_dir_all(dir) {
|
||||
Ok(_) => {
|
||||
println!("Successfully created directory");
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error: Unable to create the directory {err:?}");
|
||||
}
|
||||
match repo_queue::song::get_data(&pool, &payload.song_queue_id).await {
|
||||
Ok(data) => {
|
||||
song.data = data;
|
||||
let dir = std::path::Path::new(&song.directory);
|
||||
if !dir.exists() {
|
||||
println!("Creating directory");
|
||||
match std::fs::create_dir_all(dir) {
|
||||
Ok(_) => {
|
||||
println!("Successfully created directory");
|
||||
}
|
||||
}
|
||||
|
||||
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),
|
||||
)
|
||||
eprintln!("Error: Unable to create the directory {err:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
|
||||
|
||||
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) => {
|
||||
response.message = err.to_string();
|
||||
(axum::http::StatusCode::BAD_REQUEST, axum::Json(response))
|
||||
@@ -296,90 +280,40 @@ pub mod endpoint {
|
||||
axum::extract::Path(id): axum::extract::Path<uuid::Uuid>,
|
||||
) -> impl IntoResponse {
|
||||
match repo::song::get_song(&pool, &id).await {
|
||||
Ok(mut song) => {
|
||||
let lab_config = crate::util::maze::get_config();
|
||||
let lr = labyrinth::Labyrinth { config: lab_config };
|
||||
Ok(song) => {
|
||||
let song_path = song.song_path().unwrap();
|
||||
let path = std::path::Path::new(&song_path);
|
||||
|
||||
match lr.download(&song.file_key).await {
|
||||
Ok(data) => {
|
||||
song.filename = simodels::song::generate_filename(
|
||||
simodels::types::MusicType::FlacExtension,
|
||||
true,
|
||||
)
|
||||
.unwrap();
|
||||
// TODO: At some point, directory will no longer be needed with s3
|
||||
song.directory = sienvy::environment::get_root_directory().value;
|
||||
song.data = data;
|
||||
|
||||
match song.save_to_filesystem() {
|
||||
Ok(_) => {
|
||||
let song_path = song.song_path().unwrap();
|
||||
let path = std::path::Path::new(&song_path);
|
||||
|
||||
if !path.starts_with(&song.directory) || !path.exists() {
|
||||
return Err((
|
||||
axum::http::StatusCode::NOT_FOUND,
|
||||
"File not found",
|
||||
));
|
||||
}
|
||||
|
||||
let file = match tokio::fs::File::open(&path).await {
|
||||
Ok(file) => file,
|
||||
Err(_) => {
|
||||
return Err((
|
||||
axum::http::StatusCode::NOT_FOUND,
|
||||
"File not found",
|
||||
));
|
||||
}
|
||||
};
|
||||
|
||||
let file_size = match file.metadata().await {
|
||||
Ok(meta) => meta.len(),
|
||||
Err(_) => {
|
||||
return Err((
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
"Could not read file",
|
||||
));
|
||||
}
|
||||
};
|
||||
|
||||
let mime = mime_guess::from_path(path).first_or_octet_stream();
|
||||
let stream = tokio_util::io::ReaderStream::new(file);
|
||||
|
||||
let rep = axum::response::Response::builder()
|
||||
.header("content-type", mime.to_string())
|
||||
.header("accept-ranges", "bytes")
|
||||
.header("content-length", file_size.to_string())
|
||||
.body(axum::body::Body::from_stream(stream))
|
||||
.unwrap();
|
||||
match song.remove_from_filesystem() {
|
||||
Ok(_) => Ok(rep),
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
Err((
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
"Could not read file",
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
Err((
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
"Could not find file",
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
Err((
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
"Could not find file",
|
||||
))
|
||||
}
|
||||
if !path.starts_with(&song.directory) || !path.exists() {
|
||||
return Err((axum::http::StatusCode::NOT_FOUND, "File not found"));
|
||||
}
|
||||
|
||||
let file = match tokio::fs::File::open(&path).await {
|
||||
Ok(file) => file,
|
||||
Err(_) => return Err((axum::http::StatusCode::NOT_FOUND, "File not found")),
|
||||
};
|
||||
|
||||
let file_size = match file.metadata().await {
|
||||
Ok(meta) => meta.len(),
|
||||
Err(_) => {
|
||||
return Err((
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
"Could not read file",
|
||||
));
|
||||
}
|
||||
};
|
||||
|
||||
let mime = mime_guess::from_path(path).first_or_octet_stream();
|
||||
let stream = tokio_util::io::ReaderStream::new(file);
|
||||
|
||||
let rep = axum::response::Response::builder()
|
||||
.header("content-type", mime.to_string())
|
||||
.header("accept-ranges", "bytes")
|
||||
.header("content-length", file_size.to_string())
|
||||
.body(axum::body::Body::from_stream(stream))
|
||||
.unwrap();
|
||||
|
||||
Ok(rep)
|
||||
}
|
||||
Err(_err) => Err((
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
@@ -403,11 +337,8 @@ 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::song::get_song(&pool, &id).await {
|
||||
Ok(song) => match lr.download(&song.file_key).await {
|
||||
Ok(song) => match simodels::song::io::to_data(&song) {
|
||||
Ok(data) => {
|
||||
let bytes = axum::body::Bytes::from(data);
|
||||
let mut response = bytes.into_response();
|
||||
@@ -456,8 +387,6 @@ pub mod endpoint {
|
||||
axum::Json<super::response::delete_song::Response>,
|
||||
) {
|
||||
let mut response = super::response::delete_song::Response::default();
|
||||
let lab_config = crate::util::maze::get_config();
|
||||
let lr = labyrinth::Labyrinth { config: lab_config };
|
||||
|
||||
match repo::song::get_song(&pool, &id).await {
|
||||
Ok(song) => {
|
||||
@@ -481,7 +410,7 @@ pub mod endpoint {
|
||||
match repo::coverart::delete_coverart(&pool, &coverart.id).await
|
||||
{
|
||||
Ok(deleted_coverart) => {
|
||||
match lr.delete(&song.file_key).await {
|
||||
match song.remove_from_filesystem() {
|
||||
Ok(_) => match coverart.remove_from_filesystem() {
|
||||
Ok(_) => {
|
||||
response.message = String::from(
|
||||
@@ -499,7 +428,7 @@ pub mod endpoint {
|
||||
}
|
||||
},
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
response.message = err.to_string();
|
||||
(axum::http::StatusCode::INTERNAL_SERVER_ERROR, axum::Json(response))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
pub mod auth;
|
||||
pub mod callers;
|
||||
pub mod config;
|
||||
pub mod db;
|
||||
pub mod repo;
|
||||
pub mod util;
|
||||
+149
-225
@@ -1,12 +1,18 @@
|
||||
pub mod auth;
|
||||
pub mod callers;
|
||||
pub mod config;
|
||||
pub mod db;
|
||||
pub mod repo;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
// initialize tracing
|
||||
tracing_subscriber::fmt::init();
|
||||
|
||||
match tokio::net::TcpListener::bind(soaricarus_api::config::host::get_full()).await {
|
||||
match tokio::net::TcpListener::bind(config::host::get_full()).await {
|
||||
Ok(listener) => {
|
||||
// build our application with routes
|
||||
let app = soaricarus_api::config::init::app().await;
|
||||
let app = config::init::app().await;
|
||||
axum::serve(listener, app).await.unwrap();
|
||||
}
|
||||
Err(err) => {
|
||||
@@ -19,9 +25,14 @@ async fn main() {
|
||||
mod tests {
|
||||
use std::io::Write;
|
||||
|
||||
/*
|
||||
use common_multipart_rfc7578::client::multipart::{
|
||||
Body as MultipartBody, Form as MultipartForm,
|
||||
};
|
||||
*/
|
||||
use tower::ServiceExt;
|
||||
|
||||
use soaricarus_api::db;
|
||||
use crate::db;
|
||||
|
||||
mod db_mgr {
|
||||
use std::str::FromStr;
|
||||
@@ -105,7 +116,7 @@ mod tests {
|
||||
use std::time::Duration;
|
||||
|
||||
pub async fn app(pool: sqlx::PgPool) -> axum::Router {
|
||||
soaricarus_api::config::init::routes()
|
||||
crate::config::init::routes()
|
||||
.await
|
||||
.layer(axum::Extension(pool))
|
||||
.layer(axum::extract::DefaultBodyLimit::max(1024 * 1024 * 1024))
|
||||
@@ -191,7 +202,7 @@ mod tests {
|
||||
"flac".to_string(),
|
||||
"tests/I/track01.flac".to_string(),
|
||||
))),
|
||||
soaricarus_api::callers::queue::endpoints::QUEUESONG,
|
||||
crate::callers::queue::endpoints::QUEUESONG,
|
||||
axum::http::Method::POST,
|
||||
true,
|
||||
)
|
||||
@@ -215,7 +226,7 @@ mod tests {
|
||||
|
||||
match run_post(
|
||||
Some(ReqBody::Json(payload)),
|
||||
soaricarus_api::callers::queue::endpoints::QUEUESONGLINKUSERID,
|
||||
crate::callers::queue::endpoints::QUEUESONGLINKUSERID,
|
||||
axum::http::Method::PATCH,
|
||||
true,
|
||||
)
|
||||
@@ -234,7 +245,7 @@ mod tests {
|
||||
) -> Result<axum::response::Response, axum::http::Error> {
|
||||
match run_post(
|
||||
None,
|
||||
soaricarus_api::callers::queue::endpoints::NEXTQUEUESONG,
|
||||
crate::callers::queue::endpoints::NEXTQUEUESONG,
|
||||
axum::http::Method::GET,
|
||||
false,
|
||||
)
|
||||
@@ -254,7 +265,7 @@ mod tests {
|
||||
) -> Result<axum::response::Response, axum::http::Error> {
|
||||
let uri = format!(
|
||||
"{}?id={}",
|
||||
soaricarus_api::callers::queue::endpoints::QUEUEMETADATA,
|
||||
crate::callers::queue::endpoints::QUEUEMETADATA,
|
||||
id
|
||||
);
|
||||
|
||||
@@ -271,7 +282,7 @@ mod tests {
|
||||
app: &axum::Router,
|
||||
id: &uuid::Uuid,
|
||||
) -> Result<axum::response::Response, axum::http::Error> {
|
||||
let raw_uri = String::from(soaricarus_api::callers::queue::endpoints::QUEUESONGDATA);
|
||||
let raw_uri = String::from(crate::callers::queue::endpoints::QUEUESONGDATA);
|
||||
let end_index = raw_uri.len() - 4;
|
||||
let mut uri: String = (&raw_uri[..end_index]).to_string();
|
||||
uri += &id.to_string();
|
||||
@@ -293,7 +304,7 @@ mod tests {
|
||||
simeta::detection::coverart::constants::JPEG_TYPE.to_string(),
|
||||
"tests/I/Coverart-1.jpg".to_string(),
|
||||
))),
|
||||
soaricarus_api::callers::queue::endpoints::QUEUECOVERART,
|
||||
crate::callers::queue::endpoints::QUEUECOVERART,
|
||||
axum::http::Method::POST,
|
||||
true,
|
||||
)
|
||||
@@ -315,7 +326,7 @@ mod tests {
|
||||
|
||||
match run_post(
|
||||
Some(ReqBody::Json(payload)),
|
||||
soaricarus_api::callers::queue::endpoints::QUEUEMETADATA,
|
||||
crate::callers::queue::endpoints::QUEUEMETADATA,
|
||||
axum::http::Method::POST,
|
||||
true,
|
||||
)
|
||||
@@ -342,7 +353,7 @@ mod tests {
|
||||
|
||||
match run_post(
|
||||
Some(ReqBody::Json(payload)),
|
||||
soaricarus_api::callers::queue::endpoints::QUEUECOVERARTLINK,
|
||||
crate::callers::queue::endpoints::QUEUECOVERARTLINK,
|
||||
axum::http::Method::PATCH,
|
||||
true,
|
||||
)
|
||||
@@ -365,7 +376,7 @@ mod tests {
|
||||
|
||||
match run_post(
|
||||
Some(ReqBody::Json(payload)),
|
||||
soaricarus_api::callers::endpoints::CREATECOVERART,
|
||||
crate::callers::endpoints::CREATECOVERART,
|
||||
axum::http::Method::POST,
|
||||
true,
|
||||
)
|
||||
@@ -388,7 +399,7 @@ mod tests {
|
||||
|
||||
match run_post(
|
||||
Some(ReqBody::Json(payload)),
|
||||
soaricarus_api::callers::endpoints::CREATESONG,
|
||||
crate::callers::endpoints::CREATESONG,
|
||||
axum::http::Method::POST,
|
||||
true,
|
||||
)
|
||||
@@ -411,7 +422,7 @@ mod tests {
|
||||
|
||||
match run_post(
|
||||
Some(ReqBody::Json(payload)),
|
||||
soaricarus_api::callers::queue::endpoints::QUEUESONG,
|
||||
crate::callers::queue::endpoints::QUEUESONG,
|
||||
axum::http::Method::PATCH,
|
||||
true,
|
||||
)
|
||||
@@ -431,7 +442,7 @@ mod tests {
|
||||
) -> Result<axum::response::Response, axum::http::Error> {
|
||||
let uri = format!(
|
||||
"{}?id={}",
|
||||
soaricarus_api::callers::queue::endpoints::QUEUECOVERART,
|
||||
crate::callers::queue::endpoints::QUEUECOVERART,
|
||||
coverart_queue_id
|
||||
);
|
||||
|
||||
@@ -440,8 +451,27 @@ mod tests {
|
||||
Ok(response) => Ok(response),
|
||||
Err(err) => Err(axum::http::Error::from(err)),
|
||||
},
|
||||
Err(err) => Err(err),
|
||||
Err(err) => {
|
||||
Err(err)
|
||||
// Err(std::convert::Infallible::from(err))
|
||||
// Err(err)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
let req = axum::http::Request::builder()
|
||||
.method(axum::http::Method::GET)
|
||||
.uri(uri)
|
||||
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
||||
.header(
|
||||
axum::http::header::AUTHORIZATION,
|
||||
super::bearer_auth().await,
|
||||
)
|
||||
.body(axum::body::Body::empty())
|
||||
.unwrap();
|
||||
|
||||
app.clone().oneshot(req).await
|
||||
*/
|
||||
}
|
||||
|
||||
pub enum ReqBody {
|
||||
@@ -450,6 +480,7 @@ mod tests {
|
||||
}
|
||||
|
||||
pub async fn run_post(
|
||||
// payload: Option<&serde_json::Value>,
|
||||
payload: Option<ReqBody>,
|
||||
uri: &str,
|
||||
method: axum::http::Method,
|
||||
@@ -462,7 +493,7 @@ mod tests {
|
||||
payload.is_some(),
|
||||
"Has request body and payload has data"
|
||||
);
|
||||
|
||||
// axum::body::Body::from(payload.unwrap().to_string())
|
||||
match payload {
|
||||
Some(p) => match p {
|
||||
ReqBody::Json(val) => axum::body::Body::from(val.to_string()),
|
||||
@@ -470,8 +501,12 @@ mod tests {
|
||||
let mut form = MultipartForm::default();
|
||||
let _ = form.add_file(t, p);
|
||||
|
||||
// Create request
|
||||
// let content_type = form.content_type();
|
||||
content_type = form.content_type();
|
||||
println!("Content: {content_type:?}");
|
||||
let body = MultipartBody::from(form);
|
||||
println!("Streaming");
|
||||
axum::body::Body::from_stream(body)
|
||||
}
|
||||
},
|
||||
@@ -486,7 +521,11 @@ mod tests {
|
||||
match axum::http::Request::builder()
|
||||
.method(method)
|
||||
.uri(uri)
|
||||
.header(axum::http::header::CONTENT_TYPE, content_type)
|
||||
.header(
|
||||
axum::http::header::CONTENT_TYPE,
|
||||
content_type,
|
||||
// "application/json; charset=utf-8",
|
||||
)
|
||||
.header(
|
||||
axum::http::header::AUTHORIZATION,
|
||||
super::bearer_auth().await,
|
||||
@@ -500,132 +539,14 @@ mod tests {
|
||||
}
|
||||
|
||||
mod sequence_flow {
|
||||
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 {
|
||||
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 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 tokio::fs::File::open(p).await {
|
||||
Ok(mut _file) => {
|
||||
let data = labyrinth::Data {
|
||||
filepath: song.path.clone(),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
match lr.upload(&song.file_key, &data).await {
|
||||
Ok(_) => {}
|
||||
Err(err) => {
|
||||
assert!(false, "Error: {err:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
assert!(false, "Error: {err:?}");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
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 lab_config = soaricarus_api::util::maze::get_config();
|
||||
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::<
|
||||
soaricarus_api::callers::queue::song::response::song_queue::Response,
|
||||
crate::callers::queue::song::response::song_queue::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||
@@ -639,7 +560,7 @@ mod tests {
|
||||
{
|
||||
Ok(response) => {
|
||||
let resp = super::util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::song::response::link_user_id::Response,
|
||||
crate::callers::queue::song::response::link_user_id::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(
|
||||
@@ -651,7 +572,7 @@ mod tests {
|
||||
match super::request::queue_metadata_req(&app, &song_queue_id).await {
|
||||
Ok(response) => {
|
||||
let resp = super::util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::song::response::song_queue::Response,
|
||||
crate::callers::queue::song::response::song_queue::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||
@@ -664,7 +585,10 @@ mod tests {
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
}
|
||||
Err(err) => Err(err),
|
||||
Err(err) => {
|
||||
assert!(false, "Error: {:?}", err);
|
||||
Err(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => Err(err),
|
||||
@@ -679,11 +603,10 @@ 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::<
|
||||
soaricarus_api::callers::queue::coverart::response::queue::Response,
|
||||
crate::callers::queue::coverart::response::queue::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||
@@ -699,7 +622,7 @@ mod tests {
|
||||
{
|
||||
Ok(response) => {
|
||||
let resp = super::util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::coverart::response::link::Response,
|
||||
crate::callers::queue::coverart::response::link::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||
@@ -715,10 +638,16 @@ mod tests {
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
}
|
||||
Err(err) => Err(err),
|
||||
Err(err) => {
|
||||
assert!(false, "Error: {:?}", err);
|
||||
Err(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => Err(err),
|
||||
Err(err) => {
|
||||
assert!(false, "Error: {:?}", err);
|
||||
Err(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -729,7 +658,7 @@ mod tests {
|
||||
match queue_song_flow(&app).await {
|
||||
Ok((song_response, user_id)) => {
|
||||
let resp = super::util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::metadata::response::fetch_metadata::Response,
|
||||
crate::callers::queue::metadata::response::fetch_metadata::Response,
|
||||
>(song_response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Data should not be empty");
|
||||
@@ -738,7 +667,7 @@ mod tests {
|
||||
match super::request::create_song_req(&app, &song_queue_id, &user_id).await {
|
||||
Ok(response) => {
|
||||
let resp = super::util::get_resp_data::<
|
||||
soaricarus_api::callers::song::response::create_metadata::Response,
|
||||
crate::callers::song::response::create_metadata::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(
|
||||
@@ -756,6 +685,8 @@ mod tests {
|
||||
song
|
||||
);
|
||||
|
||||
eprintln!("Song: {:?}", song);
|
||||
|
||||
match queue_coverart_flow(&app, &song_queue_id).await {
|
||||
Ok(response) => Ok((response, song_queue_id)),
|
||||
Err(err) => {
|
||||
@@ -854,7 +785,7 @@ mod tests {
|
||||
) -> serde_json::Value {
|
||||
serde_json::json!({
|
||||
"id": song_queue_id,
|
||||
"status": soaricarus_api::repo::queue::song::status::READY
|
||||
"status": crate::repo::queue::song::status::READY
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -879,22 +810,24 @@ mod tests {
|
||||
let app = init::app(pool).await;
|
||||
|
||||
// Send request
|
||||
println!("Trying");
|
||||
match request::song_queue_req(&app).await {
|
||||
Ok(response) => {
|
||||
println!("response: {response:?}");
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::song::response::song_queue::Response,
|
||||
crate::callers::queue::song::response::song_queue::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||
assert_eq!(false, resp.data[0].is_nil(), "Should not be empty");
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Failure!");
|
||||
assert!(false, "Error: {:?}", err);
|
||||
}
|
||||
};
|
||||
|
||||
let _ = db_mgr::drop_database(&tm_pool, &db_name).await;
|
||||
sequence_flow::delete_test_songs_from_bucket().await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -919,7 +852,7 @@ mod tests {
|
||||
match request::song_queue_req(&app).await {
|
||||
Ok(response) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::song::response::song_queue::Response,
|
||||
crate::callers::queue::song::response::song_queue::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||
@@ -932,7 +865,7 @@ mod tests {
|
||||
match request::song_queue_link_req(&app, &song_queue_id, &user_id).await {
|
||||
Ok(response) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::song::response::link_user_id::Response,
|
||||
crate::callers::queue::song::response::link_user_id::Response,
|
||||
>(response)
|
||||
.await;
|
||||
let collected_user_id = &resp.data[0];
|
||||
@@ -984,20 +917,20 @@ mod tests {
|
||||
match sequence_flow::queue_song_and_coverart_flow(&app).await {
|
||||
Ok((resp_one, song_queue_id)) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::coverart::response::fetch_coverart_no_data::Response,
|
||||
crate::callers::queue::coverart::response::fetch_coverart_no_data::Response,
|
||||
>(resp_one)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||
|
||||
let _resp_coverart_queue_id = resp.data[0].id;
|
||||
|
||||
let old = soaricarus_api::repo::queue::song::status::PENDING;
|
||||
let target_status = soaricarus_api::repo::queue::song::status::READY;
|
||||
let old = crate::repo::queue::song::status::PENDING;
|
||||
let target_status = crate::repo::queue::song::status::READY;
|
||||
|
||||
match request::update_song_queue_status_req(&app, &song_queue_id).await {
|
||||
Ok(response) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::song::response::update_status::Response,
|
||||
crate::callers::queue::song::response::update_status::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||
@@ -1012,7 +945,7 @@ mod tests {
|
||||
match request::fetch_queue_req(&app).await {
|
||||
Ok(response) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::song::response::fetch_queue_song::Response,
|
||||
crate::callers::queue::song::response::fetch_queue_song::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||
@@ -1058,7 +991,7 @@ mod tests {
|
||||
match request::song_queue_req(&app).await {
|
||||
Ok(response) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::song::response::song_queue::Response,
|
||||
crate::callers::queue::song::response::song_queue::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||
@@ -1092,9 +1025,8 @@ mod tests {
|
||||
}
|
||||
let songpath = song.song_path().unwrap();
|
||||
|
||||
let raw_uri = String::from(
|
||||
soaricarus_api::callers::queue::endpoints::QUEUESONGUPDATE,
|
||||
);
|
||||
let raw_uri =
|
||||
String::from(crate::callers::queue::endpoints::QUEUESONGUPDATE);
|
||||
let end_index = raw_uri.len() - 5;
|
||||
|
||||
let uri = format!(
|
||||
@@ -1122,7 +1054,7 @@ mod tests {
|
||||
{
|
||||
Ok(response) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::song::response::update_song_queue::Response,
|
||||
crate::callers::queue::song::response::update_song_queue::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||
@@ -1179,7 +1111,7 @@ mod tests {
|
||||
match request::song_queue_req(&app).await {
|
||||
Ok(response) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::song::response::song_queue::Response,
|
||||
crate::callers::queue::song::response::song_queue::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||
@@ -1230,20 +1162,20 @@ mod tests {
|
||||
match sequence_flow::queue_song_and_coverart_flow(&app).await {
|
||||
Ok((resp_one, song_queue_id)) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::coverart::response::fetch_coverart_no_data::Response,
|
||||
crate::callers::queue::coverart::response::fetch_coverart_no_data::Response,
|
||||
>(resp_one)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||
|
||||
let _resp_coverart_queue_id = resp.data[0].id;
|
||||
|
||||
let old = soaricarus_api::repo::queue::song::status::PENDING;
|
||||
let done = soaricarus_api::repo::queue::song::status::READY;
|
||||
let old = crate::repo::queue::song::status::PENDING;
|
||||
let done = crate::repo::queue::song::status::READY;
|
||||
|
||||
match request::update_song_queue_status_req(&app, &song_queue_id).await {
|
||||
Ok(response) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::song::response::update_status::Response,
|
||||
crate::callers::queue::song::response::update_status::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||
@@ -1288,7 +1220,7 @@ mod tests {
|
||||
match request::song_queue_req(&app).await {
|
||||
Ok(response) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::song::response::song_queue::Response,
|
||||
crate::callers::queue::song::response::song_queue::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||
@@ -1297,7 +1229,7 @@ mod tests {
|
||||
match request::queue_metadata_req(&app, &resp.data[0]).await {
|
||||
Ok(response) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::song::response::song_queue::Response,
|
||||
crate::callers::queue::song::response::song_queue::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||
@@ -1338,7 +1270,7 @@ mod tests {
|
||||
match sequence_flow::queue_song_flow(&app).await {
|
||||
Ok((response, _user_id)) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::metadata::response::fetch_metadata::Response,
|
||||
crate::callers::queue::metadata::response::fetch_metadata::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Data should not be empty");
|
||||
@@ -1374,7 +1306,7 @@ mod tests {
|
||||
match request::upload_coverart_queue_req(&app).await {
|
||||
Ok(response) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::coverart::response::queue::Response,
|
||||
crate::callers::queue::coverart::response::queue::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||
@@ -1411,7 +1343,7 @@ mod tests {
|
||||
match request::song_queue_req(&app).await {
|
||||
Ok(response) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::coverart::response::queue::Response,
|
||||
crate::callers::queue::coverart::response::queue::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||
@@ -1422,7 +1354,7 @@ mod tests {
|
||||
match request::upload_coverart_queue_req(&app).await {
|
||||
Ok(response) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::coverart::response::queue::Response,
|
||||
crate::callers::queue::coverart::response::queue::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||
@@ -1438,7 +1370,7 @@ mod tests {
|
||||
{
|
||||
Ok(response) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::coverart::response::link::Response,
|
||||
crate::callers::queue::coverart::response::link::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||
@@ -1492,7 +1424,7 @@ mod tests {
|
||||
match request::song_queue_req(&app).await {
|
||||
Ok(response) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::coverart::response::queue::Response,
|
||||
crate::callers::queue::coverart::response::queue::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||
@@ -1502,7 +1434,7 @@ mod tests {
|
||||
match sequence_flow::queue_coverart_flow(&app, &song_queue_id).await {
|
||||
Ok(response) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::coverart::response::fetch_coverart_no_data::Response,
|
||||
crate::callers::queue::coverart::response::fetch_coverart_no_data::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||
@@ -1542,7 +1474,7 @@ mod tests {
|
||||
match request::song_queue_req(&app).await {
|
||||
Ok(response) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::coverart::response::queue::Response,
|
||||
crate::callers::queue::coverart::response::queue::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||
@@ -1553,7 +1485,7 @@ mod tests {
|
||||
match request::upload_coverart_queue_req(&app).await {
|
||||
Ok(response) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::coverart::response::queue::Response,
|
||||
crate::callers::queue::coverart::response::queue::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||
@@ -1569,7 +1501,7 @@ mod tests {
|
||||
{
|
||||
Ok(response) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::coverart::response::link::Response,
|
||||
crate::callers::queue::coverart::response::link::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||
@@ -1584,7 +1516,7 @@ mod tests {
|
||||
);
|
||||
|
||||
let raw_uri = String::from(
|
||||
soaricarus_api::callers::queue::endpoints::QUEUECOVERARTDATA,
|
||||
crate::callers::queue::endpoints::QUEUECOVERARTDATA,
|
||||
);
|
||||
let end_index = raw_uri.len() - 5;
|
||||
let uri = format!(
|
||||
@@ -1675,7 +1607,7 @@ mod tests {
|
||||
match sequence_flow::queue_song_flow(&app).await {
|
||||
Ok((response, user_id)) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::metadata::response::fetch_metadata::Response,
|
||||
crate::callers::queue::metadata::response::fetch_metadata::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Data should not be empty");
|
||||
@@ -1684,7 +1616,7 @@ mod tests {
|
||||
match request::create_song_req(&app, &song_q_id, &user_id).await {
|
||||
Ok(response) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::song::response::create_metadata::Response,
|
||||
crate::callers::song::response::create_metadata::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(
|
||||
@@ -1738,7 +1670,7 @@ mod tests {
|
||||
match sequence_flow::queue_song_flow(&app).await {
|
||||
Ok((response, user_id)) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::metadata::response::fetch_metadata::Response,
|
||||
crate::callers::queue::metadata::response::fetch_metadata::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Data should not be empty");
|
||||
@@ -1747,7 +1679,7 @@ mod tests {
|
||||
match request::create_song_req(&app, &song_queue_id, &user_id).await {
|
||||
Ok(response) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::song::response::create_metadata::Response,
|
||||
crate::callers::song::response::create_metadata::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(
|
||||
@@ -1768,7 +1700,7 @@ mod tests {
|
||||
match sequence_flow::queue_coverart_flow(&app, &song_queue_id).await {
|
||||
Ok(response) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::coverart::response::fetch_coverart_no_data::Response,
|
||||
crate::callers::queue::coverart::response::fetch_coverart_no_data::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||
@@ -1783,7 +1715,7 @@ mod tests {
|
||||
{
|
||||
Ok(response) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::coverart::response::create_coverart::Response,
|
||||
crate::callers::coverart::response::create_coverart::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(
|
||||
@@ -1838,7 +1770,7 @@ mod tests {
|
||||
match sequence_flow::queue_song_flow(&app).await {
|
||||
Ok((response, user_id)) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::metadata::response::fetch_metadata::Response,
|
||||
crate::callers::queue::metadata::response::fetch_metadata::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Data should not be empty");
|
||||
@@ -1847,7 +1779,7 @@ mod tests {
|
||||
match request::create_song_req(&app, &song_q_id, &user_id).await {
|
||||
Ok(response) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::song::response::create_metadata::Response,
|
||||
crate::callers::song::response::create_metadata::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(
|
||||
@@ -1872,19 +1804,18 @@ mod tests {
|
||||
match app
|
||||
.clone()
|
||||
.oneshot(
|
||||
request::run_post(
|
||||
Some(request::ReqBody::Json(payload)),
|
||||
soaricarus_api::callers::queue::endpoints::QUEUESONGDATAWIPE,
|
||||
axum::http::Method::PATCH,
|
||||
true,
|
||||
)
|
||||
.await
|
||||
.unwrap(),
|
||||
axum::http::Request::builder()
|
||||
.method(axum::http::Method::PATCH)
|
||||
.uri(crate::callers::queue::endpoints::QUEUESONGDATAWIPE)
|
||||
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
||||
.header(axum::http::header::AUTHORIZATION, bearer_auth().await)
|
||||
.body(axum::body::Body::from(payload.to_string()))
|
||||
.unwrap(),
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(response) => {
|
||||
let resp = util::get_resp_data::<soaricarus_api::callers::queue::song::response::wipe_data_from_song_queue::Response>(response).await;
|
||||
let resp = util::get_resp_data::<crate::callers::queue::song::response::wipe_data_from_song_queue::Response>(response).await;
|
||||
assert_eq!(
|
||||
false,
|
||||
resp.data.is_empty(),
|
||||
@@ -1945,7 +1876,7 @@ mod tests {
|
||||
match sequence_flow::queue_song_flow(&app).await {
|
||||
Ok((response, user_id)) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::metadata::response::fetch_metadata::Response,
|
||||
crate::callers::queue::metadata::response::fetch_metadata::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Data should not be empty");
|
||||
@@ -1954,7 +1885,7 @@ mod tests {
|
||||
match request::create_song_req(&app, &song_queue_id, &user_id).await {
|
||||
Ok(response) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::song::response::create_metadata::Response,
|
||||
crate::callers::song::response::create_metadata::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(
|
||||
@@ -1977,7 +1908,7 @@ mod tests {
|
||||
match sequence_flow::queue_coverart_flow(&app, &song_queue_id).await {
|
||||
Ok(response) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::coverart::response::fetch_coverart_no_data::Response,
|
||||
crate::callers::queue::coverart::response::fetch_coverart_no_data::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||
@@ -1993,7 +1924,7 @@ mod tests {
|
||||
.oneshot(
|
||||
request::run_post(
|
||||
Some(request::ReqBody::Json(payload)),
|
||||
soaricarus_api::callers::queue::endpoints::QUEUECOVERARTDATAWIPE,
|
||||
crate::callers::queue::endpoints::QUEUECOVERARTDATAWIPE,
|
||||
axum::http::Method::PATCH,
|
||||
true,
|
||||
)
|
||||
@@ -2004,7 +1935,7 @@ mod tests {
|
||||
{
|
||||
Ok(response) => {
|
||||
let resp = util::get_resp_data::<
|
||||
soaricarus_api::callers::queue::coverart::response::wipe_data_from_coverart_queue::Response,
|
||||
crate::callers::queue::coverart::response::wipe_data_from_coverart_queue::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(
|
||||
@@ -2061,7 +1992,7 @@ mod tests {
|
||||
|
||||
let (id, _, _, _) = test_data::song_id().await.unwrap();
|
||||
|
||||
let uri = format!("{}?id={id}", soaricarus_api::callers::endpoints::GETSONGS);
|
||||
let uri = format!("{}?id={id}", crate::callers::endpoints::GETSONGS);
|
||||
|
||||
match app
|
||||
.clone()
|
||||
@@ -2074,7 +2005,7 @@ mod tests {
|
||||
{
|
||||
Ok(response) => {
|
||||
let resp = super::util::get_resp_data::<
|
||||
soaricarus_api::callers::song::response::get_songs::Response,
|
||||
crate::callers::song::response::get_songs::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||
@@ -2111,10 +2042,7 @@ mod tests {
|
||||
|
||||
let id = test_data::coverart_id().await.unwrap();
|
||||
|
||||
let uri = format!(
|
||||
"{}?id={id}",
|
||||
soaricarus_api::callers::endpoints::GETCOVERART
|
||||
);
|
||||
let uri = format!("{}?id={id}", crate::callers::endpoints::GETCOVERART);
|
||||
|
||||
match app
|
||||
.clone()
|
||||
@@ -2127,7 +2055,7 @@ mod tests {
|
||||
{
|
||||
Ok(response) => {
|
||||
let resp = super::util::get_resp_data::<
|
||||
soaricarus_api::callers::coverart::response::get_coverart::Response,
|
||||
crate::callers::coverart::response::get_coverart::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||
@@ -2194,7 +2122,7 @@ mod tests {
|
||||
|
||||
let (id, _, _, _) = test_data::song_id().await.unwrap();
|
||||
|
||||
let my_url = soaricarus_api::callers::endpoints::STREAMSONG;
|
||||
let my_url = crate::callers::endpoints::STREAMSONG;
|
||||
let last = my_url.len() - 5;
|
||||
let uri = format!("{}/{id}", &my_url[0..last]);
|
||||
|
||||
@@ -2248,11 +2176,9 @@ mod tests {
|
||||
|
||||
let (id, _, _, _) = test_data::song_id().await.unwrap();
|
||||
|
||||
let uri = super::util::format_url_with_value(
|
||||
soaricarus_api::callers::endpoints::DOWNLOADSONG,
|
||||
&id,
|
||||
)
|
||||
.await;
|
||||
let uri =
|
||||
super::util::format_url_with_value(crate::callers::endpoints::DOWNLOADSONG, &id)
|
||||
.await;
|
||||
|
||||
match app
|
||||
.clone()
|
||||
@@ -2305,7 +2231,7 @@ mod tests {
|
||||
let id = test_data::coverart_id().await.unwrap();
|
||||
|
||||
let uri = super::util::format_url_with_value(
|
||||
soaricarus_api::callers::endpoints::DOWNLOADCOVERART,
|
||||
crate::callers::endpoints::DOWNLOADCOVERART,
|
||||
&id,
|
||||
)
|
||||
.await;
|
||||
@@ -2427,11 +2353,9 @@ mod tests {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let uri = super::util::format_url_with_value(
|
||||
soaricarus_api::callers::endpoints::DELETESONG,
|
||||
&id,
|
||||
)
|
||||
.await;
|
||||
let uri =
|
||||
super::util::format_url_with_value(crate::callers::endpoints::DELETESONG, &id)
|
||||
.await;
|
||||
|
||||
match app
|
||||
.clone()
|
||||
@@ -2444,7 +2368,7 @@ mod tests {
|
||||
{
|
||||
Ok(response) => {
|
||||
let resp = super::util::get_resp_data::<
|
||||
soaricarus_api::callers::song::response::delete_song::Response,
|
||||
crate::callers::song::response::delete_song::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Response has no data");
|
||||
@@ -2504,7 +2428,7 @@ mod tests {
|
||||
.oneshot(
|
||||
super::request::run_post(
|
||||
None,
|
||||
soaricarus_api::callers::endpoints::GETALLSONGS,
|
||||
crate::callers::endpoints::GETALLSONGS,
|
||||
axum::http::Method::GET,
|
||||
false,
|
||||
)
|
||||
@@ -2515,7 +2439,7 @@ mod tests {
|
||||
{
|
||||
Ok(response) => {
|
||||
let resp = super::util::get_resp_data::<
|
||||
soaricarus_api::callers::song::response::get_songs::Response,
|
||||
crate::callers::song::response::get_songs::Response,
|
||||
>(response)
|
||||
.await;
|
||||
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
|
||||
|
||||
+31
-50
@@ -7,14 +7,13 @@ pub async fn create(
|
||||
) -> Result<uuid::Uuid, sqlx::Error> {
|
||||
let result = sqlx::query(
|
||||
r#"
|
||||
INSERT INTO "coverart" (title, directory, filename, file_type, file_key, song_id) VALUES($1, $2, $3, $4, $5, $6) RETURNING id;
|
||||
INSERT INTO "coverart" (title, directory, filename, file_type, song_id) VALUES($1, $2, $3, $4, $5) RETURNING id;
|
||||
"#,
|
||||
)
|
||||
.bind(&coverart.title)
|
||||
.bind(&coverart.directory)
|
||||
.bind(&coverart.filename)
|
||||
.bind(&coverart.file_type)
|
||||
.bind(&coverart.file_key)
|
||||
.bind(song_id)
|
||||
.fetch_one(pool)
|
||||
.await
|
||||
@@ -40,7 +39,7 @@ pub async fn get_coverart(
|
||||
) -> Result<simodels::coverart::CoverArt, sqlx::Error> {
|
||||
let result = sqlx::query(
|
||||
r#"
|
||||
SELECT id, title, directory, filename, file_type, file_key, song_id FROM "coverart" WHERE id = $1;
|
||||
SELECT id, title, directory, filename, file_type, song_id FROM "coverart" WHERE id = $1;
|
||||
"#,
|
||||
)
|
||||
.bind(id)
|
||||
@@ -72,10 +71,6 @@ pub async fn get_coverart(
|
||||
.try_get("file_type")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap(),
|
||||
file_key: row
|
||||
.try_get("file_key")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap(),
|
||||
song_id: row
|
||||
.try_get("song_id")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
@@ -92,7 +87,7 @@ pub async fn get_coverart_with_song_id(
|
||||
) -> Result<simodels::coverart::CoverArt, sqlx::Error> {
|
||||
let result = sqlx::query(
|
||||
r#"
|
||||
SELECT id, title, directory, filename, file_type, file_key, song_id FROM "coverart" WHERE song_id = $1;
|
||||
SELECT id, title, directory, filename, file_type, song_id FROM "coverart" WHERE song_id = $1;
|
||||
"#,
|
||||
)
|
||||
.bind(song_id)
|
||||
@@ -124,10 +119,6 @@ pub async fn get_coverart_with_song_id(
|
||||
.try_get("file_type")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap(),
|
||||
file_key: row
|
||||
.try_get("file_key")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap(),
|
||||
data: Vec::new(),
|
||||
song_id: row
|
||||
.try_get("song_id")
|
||||
@@ -146,7 +137,7 @@ pub async fn delete_coverart(
|
||||
r#"
|
||||
DELETE FROM "coverart"
|
||||
WHERE id = $1
|
||||
RETURNING id, title, directory, filename, file_type, file_key, song_id
|
||||
RETURNING id, title, directory, filename, file_type, song_id
|
||||
"#,
|
||||
)
|
||||
.bind(id)
|
||||
@@ -157,43 +148,33 @@ pub async fn delete_coverart(
|
||||
});
|
||||
|
||||
match result {
|
||||
Ok(row) => parse_row(&row).await,
|
||||
Ok(row) => Ok(simodels::coverart::CoverArt {
|
||||
id: row
|
||||
.try_get("id")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap(),
|
||||
title: row
|
||||
.try_get("title")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap(),
|
||||
directory: row
|
||||
.try_get("directory")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap(),
|
||||
filename: row
|
||||
.try_get("filename")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap(),
|
||||
file_type: row
|
||||
.try_get("file_type")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap(),
|
||||
song_id: row
|
||||
.try_get("song_id")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap(),
|
||||
data: Vec::new(),
|
||||
}),
|
||||
Err(_err) => Err(sqlx::Error::RowNotFound),
|
||||
}
|
||||
}
|
||||
|
||||
async fn parse_row(
|
||||
row: &sqlx::postgres::PgRow,
|
||||
) -> Result<simodels::coverart::CoverArt, sqlx::Error> {
|
||||
Ok(simodels::coverart::CoverArt {
|
||||
id: row
|
||||
.try_get("id")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap(),
|
||||
title: row
|
||||
.try_get("title")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap(),
|
||||
directory: row
|
||||
.try_get("directory")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap(),
|
||||
filename: row
|
||||
.try_get("filename")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap(),
|
||||
file_type: row
|
||||
.try_get("file_type")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap(),
|
||||
file_key: row
|
||||
.try_get("file_key")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap(),
|
||||
song_id: row
|
||||
.try_get("song_id")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap(),
|
||||
data: Vec::new(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
use sqlx::Row;
|
||||
|
||||
pub async fn insert(pool: &sqlx::PgPool, file_type: &str) -> Result<uuid::Uuid, sqlx::Error> {
|
||||
pub async fn insert(
|
||||
pool: &sqlx::PgPool,
|
||||
data: &Vec<u8>,
|
||||
file_type: &str,
|
||||
) -> Result<uuid::Uuid, sqlx::Error> {
|
||||
let result = sqlx::query(
|
||||
r#"
|
||||
INSERT INTO "coverartQueue" (file_type) VALUES($1) RETURNING id;
|
||||
INSERT INTO "coverartQueue" (data, file_type) VALUES($1, $2) RETURNING id;
|
||||
"#,
|
||||
)
|
||||
.bind(data)
|
||||
.bind(file_type)
|
||||
.fetch_one(pool)
|
||||
.await
|
||||
@@ -115,3 +120,78 @@ pub async fn get_coverart_queue_with_song_queue_id(
|
||||
Err(_) => Err(sqlx::Error::RowNotFound),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn get_coverart_queue_data_with_id(
|
||||
pool: &sqlx::PgPool,
|
||||
id: &uuid::Uuid,
|
||||
) -> Result<Vec<u8>, sqlx::Error> {
|
||||
let result = sqlx::query(
|
||||
r#"
|
||||
SELECT data FROM "coverartQueue" WHERE id = $1;
|
||||
"#,
|
||||
)
|
||||
.bind(id)
|
||||
.fetch_one(pool)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
eprintln!("Error querying data: {e:?}");
|
||||
});
|
||||
|
||||
match result {
|
||||
Ok(row) => Ok(row
|
||||
.try_get("data")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap()),
|
||||
Err(_) => Err(sqlx::Error::RowNotFound),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn get_coverart_queue_data_with_song_queue_id(
|
||||
pool: &sqlx::PgPool,
|
||||
song_queue_id: &uuid::Uuid,
|
||||
) -> Result<Vec<u8>, sqlx::Error> {
|
||||
let result = sqlx::query(
|
||||
r#"
|
||||
SELECT data FROM "coverartQueue" WHERE song_queue_id = $1;
|
||||
"#,
|
||||
)
|
||||
.bind(song_queue_id)
|
||||
.fetch_one(pool)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
eprintln!("Error querying data: {e}");
|
||||
});
|
||||
|
||||
match result {
|
||||
Ok(row) => Ok(row
|
||||
.try_get("data")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap()),
|
||||
Err(_) => Err(sqlx::Error::RowNotFound),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn wipe_data(
|
||||
pool: &sqlx::PgPool,
|
||||
coverart_queue_id: &uuid::Uuid,
|
||||
) -> Result<uuid::Uuid, sqlx::Error> {
|
||||
let result = sqlx::query(
|
||||
r#"
|
||||
UPDATE "coverartQueue" SET data = NULL WHERE id = $1 RETURNING id;
|
||||
"#,
|
||||
)
|
||||
.bind(coverart_queue_id)
|
||||
.fetch_one(pool)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
eprintln!("Error updating query: {e}");
|
||||
});
|
||||
|
||||
match result {
|
||||
Ok(row) => Ok(row
|
||||
.try_get("id")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap()),
|
||||
Err(_) => Err(sqlx::Error::RowNotFound),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,204 +0,0 @@
|
||||
use sqlx::Row;
|
||||
|
||||
pub async fn insert(
|
||||
pool: &sqlx::PgPool,
|
||||
file_key: &str,
|
||||
bucket: &str,
|
||||
region: &str,
|
||||
song_queue_id: &uuid::Uuid,
|
||||
) -> Result<uuid::Uuid, sqlx::Error> {
|
||||
match sqlx::query(
|
||||
r#"
|
||||
INSERT INTO "songQueueData" (file_key, bucket, region, song_queue_id) VALUES($1, $2, $3, $4) RETURNING id;
|
||||
"#,
|
||||
)
|
||||
.bind(file_key)
|
||||
.bind(bucket)
|
||||
.bind(region)
|
||||
.bind(song_queue_id)
|
||||
.fetch_one(pool).await {
|
||||
Ok(row) => {
|
||||
let id: uuid::Uuid = row.try_get("id")?;
|
||||
Ok(id)
|
||||
}
|
||||
Err(_err) => Err(sqlx::Error::RowNotFound),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn update_file_key(
|
||||
pool: &sqlx::PgPool,
|
||||
id: &uuid::Uuid,
|
||||
file_key: &str,
|
||||
) -> Result<(), sqlx::Error> {
|
||||
match sqlx::query(
|
||||
r#"
|
||||
UPDATE "songQueueData" SET file_key = $1 WHERE id = $2;
|
||||
"#,
|
||||
)
|
||||
.bind(file_key)
|
||||
.bind(id)
|
||||
.execute(pool)
|
||||
.await
|
||||
{
|
||||
Ok(_row) => Ok(()),
|
||||
Err(_) => Err(sqlx::Error::RowNotFound),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn get(
|
||||
pool: &sqlx::PgPool,
|
||||
id: &uuid::Uuid,
|
||||
) -> Result<(uuid::Uuid, String, String, String, uuid::Uuid), sqlx::Error> {
|
||||
match sqlx::query(
|
||||
r#"
|
||||
SELECT id, file_key, bucket, region, song_queue_id FROM "songQueueData"
|
||||
WHERE id = $1
|
||||
"#,
|
||||
)
|
||||
.bind(id)
|
||||
.fetch_one(pool)
|
||||
.await
|
||||
{
|
||||
Ok(row) => {
|
||||
let file_key: String = row.try_get("file_key")?;
|
||||
let bucket: String = row.try_get("bucket")?;
|
||||
let region: String = row.try_get("region")?;
|
||||
let song_queue_id: uuid::Uuid = row.try_get("song_queue_id")?;
|
||||
|
||||
Ok((*id, file_key, bucket, region, song_queue_id))
|
||||
}
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn get_with_song_queue_id(
|
||||
pool: &sqlx::PgPool,
|
||||
song_queue_id: &uuid::Uuid,
|
||||
) -> Result<(uuid::Uuid, String, String, String, uuid::Uuid), sqlx::Error> {
|
||||
match sqlx::query(
|
||||
r#"
|
||||
SELECT id, file_key, bucket, region, song_queue_id FROM "songQueueData"
|
||||
WHERE song_queue_id = $1
|
||||
"#,
|
||||
)
|
||||
.bind(song_queue_id)
|
||||
.fetch_one(pool)
|
||||
.await
|
||||
{
|
||||
Ok(row) => {
|
||||
let id: uuid::Uuid = row.try_get("id")?;
|
||||
let file_key: String = row.try_get("file_key")?;
|
||||
let bucket: String = row.try_get("bucket")?;
|
||||
let region: String = row.try_get("region")?;
|
||||
|
||||
Ok((id, file_key, bucket, region, *song_queue_id))
|
||||
}
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
}
|
||||
|
||||
pub mod queue {
|
||||
pub mod coverart {
|
||||
use sqlx::Row;
|
||||
|
||||
pub async fn insert(
|
||||
pool: &sqlx::PgPool,
|
||||
file_key: &str,
|
||||
bucket: &str,
|
||||
region: &str,
|
||||
coverart_queue_id: &uuid::Uuid,
|
||||
) -> Result<uuid::Uuid, sqlx::Error> {
|
||||
match sqlx::query(
|
||||
r#"
|
||||
INSERT INTO "coverartQueueData" (file_key, bucket, region, coverart_queue_id)
|
||||
VALUES($1, $2, $3, $4) RETURNING id;
|
||||
"#,
|
||||
)
|
||||
.bind(file_key)
|
||||
.bind(bucket)
|
||||
.bind(region)
|
||||
.bind(coverart_queue_id)
|
||||
.fetch_one(pool)
|
||||
.await
|
||||
{
|
||||
Ok(row) => {
|
||||
let id: uuid::Uuid = row.try_get("id")?;
|
||||
Ok(id)
|
||||
}
|
||||
Err(_err) => Err(sqlx::Error::RowNotFound),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn update_file_key(
|
||||
pool: &sqlx::PgPool,
|
||||
id: &uuid::Uuid,
|
||||
file_key: &str,
|
||||
) -> Result<(), sqlx::Error> {
|
||||
match sqlx::query(
|
||||
r#"
|
||||
UPDATE "coverartQueueData" SET file_key = $1 WHERE id = $2;
|
||||
"#,
|
||||
)
|
||||
.bind(file_key)
|
||||
.bind(id)
|
||||
.execute(pool)
|
||||
.await
|
||||
{
|
||||
Ok(_row) => Ok(()),
|
||||
Err(_) => Err(sqlx::Error::RowNotFound),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn get(
|
||||
pool: &sqlx::PgPool,
|
||||
id: &uuid::Uuid,
|
||||
) -> Result<(uuid::Uuid, String, String, String, uuid::Uuid), sqlx::Error> {
|
||||
match sqlx::query(
|
||||
r#"
|
||||
SELECT id, file_key, bucket, region, coverart_queue_id FROM "coverartQueueData"
|
||||
WHERE id = $1
|
||||
"#,
|
||||
)
|
||||
.bind(id)
|
||||
.fetch_one(pool)
|
||||
.await
|
||||
{
|
||||
Ok(row) => {
|
||||
let file_key: String = row.try_get("file_key")?;
|
||||
let bucket: String = row.try_get("bucket")?;
|
||||
let region: String = row.try_get("region")?;
|
||||
let coverart_queue_id: uuid::Uuid = row.try_get("coverart_queue_id")?;
|
||||
|
||||
Ok((*id, file_key, bucket, region, coverart_queue_id))
|
||||
}
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn get_with_coverart_queue_id(
|
||||
pool: &sqlx::PgPool,
|
||||
coverart_queue_id: &uuid::Uuid,
|
||||
) -> Result<(uuid::Uuid, String, String, String, uuid::Uuid), sqlx::Error> {
|
||||
match sqlx::query(
|
||||
r#"
|
||||
SELECT id, file_key, bucket, region, coverart_queue_id FROM "coverartQueueData"
|
||||
WHERE coverart_queue_id = $1
|
||||
"#,
|
||||
)
|
||||
.bind(coverart_queue_id)
|
||||
.fetch_one(pool)
|
||||
.await
|
||||
{
|
||||
Ok(row) => {
|
||||
let id: uuid::Uuid = row.try_get("id")?;
|
||||
let file_key: String = row.try_get("file_key")?;
|
||||
let bucket: String = row.try_get("bucket")?;
|
||||
let region: String = row.try_get("region")?;
|
||||
|
||||
Ok((id, file_key, bucket, region, *coverart_queue_id))
|
||||
}
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
pub mod coverart;
|
||||
pub mod data;
|
||||
pub mod metadata;
|
||||
pub mod song;
|
||||
|
||||
+51
-1
@@ -24,14 +24,16 @@ pub mod dbtype {
|
||||
|
||||
pub async fn insert(
|
||||
pool: &sqlx::PgPool,
|
||||
data: &Vec<u8>,
|
||||
filename: &String,
|
||||
status: &String,
|
||||
) -> Result<uuid::Uuid, sqlx::Error> {
|
||||
let result = sqlx::query(
|
||||
r#"
|
||||
INSERT INTO "songQueue" (filename, status) VALUES($1, $2) RETURNING id;
|
||||
INSERT INTO "songQueue" (data, filename, status) VALUES($1, $2, $3) RETURNING id;
|
||||
"#,
|
||||
)
|
||||
.bind(data)
|
||||
.bind(filename)
|
||||
.bind(status)
|
||||
.fetch_one(pool)
|
||||
@@ -251,3 +253,51 @@ pub async fn get_song_queue(
|
||||
Err(_err) => Err(sqlx::Error::RowNotFound),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn wipe_data(pool: &sqlx::PgPool, id: &uuid::Uuid) -> Result<uuid::Uuid, sqlx::Error> {
|
||||
let result = sqlx::query(
|
||||
r#"
|
||||
UPDATE "songQueue" SET data = NULL WHERE id = $1 RETURNING id;
|
||||
"#,
|
||||
)
|
||||
.bind(id)
|
||||
.fetch_one(pool)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
eprintln!("Error updating record: {e}");
|
||||
});
|
||||
|
||||
match result {
|
||||
Ok(row) => Ok(row
|
||||
.try_get("id")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap()),
|
||||
Err(_) => Err(sqlx::Error::RowNotFound),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn get_data(pool: &sqlx::PgPool, id: &uuid::Uuid) -> Result<Vec<u8>, sqlx::Error> {
|
||||
let result = sqlx::query(
|
||||
r#"
|
||||
SELECT data FROM "songQueue"
|
||||
WHERE id = $1;
|
||||
"#,
|
||||
)
|
||||
.bind(id)
|
||||
.fetch_one(pool)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
eprintln!("Error inserting: {e}");
|
||||
});
|
||||
|
||||
match result {
|
||||
Ok(row) => {
|
||||
let data = row
|
||||
.try_get("data")
|
||||
.map_err(|_e| sqlx::Error::RowNotFound)
|
||||
.unwrap();
|
||||
Ok(data)
|
||||
}
|
||||
Err(_err) => Err(sqlx::Error::RowNotFound),
|
||||
}
|
||||
}
|
||||
|
||||
+3
-16
@@ -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, 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;
|
||||
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;
|
||||
"#
|
||||
)
|
||||
.bind(&song.title)
|
||||
@@ -24,7 +24,6 @@ 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
|
||||
@@ -134,10 +133,6 @@ 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")
|
||||
@@ -233,10 +228,6 @@ 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")
|
||||
@@ -263,7 +254,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, file_key, user_id
|
||||
RETURNING id, title, artist, album, album_artist, genre, year, disc, track, track_count, disc_count, duration, audio_type, date_created, filename, directory, user_id
|
||||
"#,
|
||||
)
|
||||
.bind(id)
|
||||
@@ -341,10 +332,6 @@ 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")
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
pub mod maze {
|
||||
pub fn get_config() -> labyrinth::config::Config {
|
||||
let s3_endpoint_url = sienvy::environment::get_env("S3_ENDPOINT_URL");
|
||||
let bucket_name = sienvy::environment::get_env("S3_BUCKET_NAME");
|
||||
let region = sienvy::environment::get_env("GARAGE_S3_REGION");
|
||||
let access_key_id = sienvy::environment::get_env("GARAGE_DEFAULT_ACCESS_KEY");
|
||||
let secret_key = sienvy::environment::get_env("GARAGE_DEFAULT_SECRET_KEY");
|
||||
|
||||
labyrinth::config::Config {
|
||||
url: s3_endpoint_url.value,
|
||||
bucket: bucket_name.value,
|
||||
region: region.value,
|
||||
access_key_id: access_key_id.value,
|
||||
secret_key: secret_key.value,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,17 +6,10 @@ CREATE TABLE IF NOT EXISTS "songQueue" (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
filename TEXT NOT NULL,
|
||||
status TEXT CHECK (status IN ('pending', 'ready', 'processing', 'done')),
|
||||
data BYTEA NULL,
|
||||
user_id UUID NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "songQueueData" (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
file_key TEXT NOT NULL,
|
||||
bucket TEXT NOT NULL,
|
||||
region TEXT NOT NULL,
|
||||
song_queue_id UUID NOT NULL
|
||||
);
|
||||
|
||||
-- Table to store queued metadata
|
||||
CREATE TABLE IF NOT EXISTS "metadataQueue" (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
@@ -28,18 +21,11 @@ CREATE TABLE IF NOT EXISTS "metadataQueue" (
|
||||
-- Table to store queued coverart
|
||||
CREATE TABLE IF NOT EXISTS "coverartQueue" (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
data BYTEA NULL,
|
||||
file_type TEXT NOT NULL,
|
||||
song_queue_id UUID NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "coverartQueueData" (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
file_key TEXT NOT NULL,
|
||||
bucket TEXT NOT NULL,
|
||||
region TEXT NOT NULL,
|
||||
coverart_queue_id UUID NOT NULL
|
||||
);
|
||||
|
||||
-- Create an index for better query performance
|
||||
CREATE INDEX metadata_queue_data_metadata ON "metadataQueue" USING gin (metadata);
|
||||
|
||||
@@ -61,7 +47,6 @@ CREATE TABLE IF NOT EXISTS "song" (
|
||||
date_created timestamptz DEFAULT now(),
|
||||
filename TEXT NOT NULL,
|
||||
directory TEXT NOT NULL,
|
||||
file_key TEXT NOT NULL,
|
||||
user_id UUID NULL
|
||||
);
|
||||
|
||||
@@ -72,6 +57,5 @@ CREATE TABLE IF NOT EXISTS "coverart" (
|
||||
directory TEXT NOT NULL,
|
||||
filename TEXT NOT NULL,
|
||||
file_type TEXT NOT NULL,
|
||||
file_key TEXT NOT NULL,
|
||||
song_id UUID NOT NULL
|
||||
);
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
-- 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, 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('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 "coverart" (id, title, directory, filename, file_type, file_key, song_id)
|
||||
VALUES('996122cd-5ae9-4013-9934-60768d3006ed', 'I', 'tests/I', 'Coverart-1.jpg', 'jpeg', 'processed/coverart/Coverart-1.jpg', '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, file_key, song_id)
|
||||
VALUES('d96122cd-5ae9-4013-9934-60768d3006e9', 'I', 'tests/I', 'Coverart-2.jpg', 'jpeg', 'processed/coverart/Coverart-2.jpg', '94cf7940-34ff-489f-9124-d0ec90a55af4');
|
||||
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');
|
||||
|
||||
Reference in New Issue
Block a user