Compare commits
3 Commits
v0.2.3-dev
...
v0.2.4-dev
Author | SHA1 | Date | |
---|---|---|---|
d5e24f9114 | |||
27e4b30d21 | |||
99bb72ffb2 |
@@ -3,7 +3,6 @@ name: Release Tagging
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
|
||||||
- devel
|
- devel
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -18,7 +17,7 @@ jobs:
|
|||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.86.0
|
toolchain: 1.88.0
|
||||||
components: cargo
|
components: cargo
|
||||||
|
|
||||||
- name: Extract Version from Cargo.toml
|
- name: Extract Version from Cargo.toml
|
||||||
@@ -50,6 +49,3 @@ jobs:
|
|||||||
release_name: Release ${{ steps.version.outputs.project_tag_release }}
|
release_name: Release ${{ steps.version.outputs.project_tag_release }}
|
||||||
body: |
|
body: |
|
||||||
Release of version ${{ steps.version.outputs.project_tag_release }}
|
Release of version ${{ steps.version.outputs.project_tag_release }}
|
||||||
# draft: false
|
|
||||||
# prerelease: ${{ startsWith(github.ref, 'v') == false }} # prerelease if not a valid release tag
|
|
||||||
|
|
||||||
|
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -1255,7 +1255,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "songparser"
|
name = "songparser"
|
||||||
version = "0.2.3"
|
version = "0.2.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
"icarus_envy",
|
"icarus_envy",
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "songparser"
|
name = "songparser"
|
||||||
version = "0.2.3"
|
version = "0.2.4"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.88"
|
rust-version = "1.88"
|
||||||
|
|
||||||
|
38
src/main.rs
38
src/main.rs
@@ -21,16 +21,16 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
println!("Queue is not empty");
|
println!("Queue is not empty");
|
||||||
println!("SongQueueItem: {song_queue_item:?}");
|
println!("SongQueueItem: {song_queue_item:?}");
|
||||||
let song_queue_id = song_queue_item.data[0].id;
|
let song_queue_id = song_queue_item.data[0].id;
|
||||||
|
let user_id = song_queue_item.data[0].user_id;
|
||||||
|
|
||||||
// TODO: Do something with the result later
|
// TODO: Do something with the result later
|
||||||
match some_work(&app_base_url, &song_queue_id).await {
|
match some_work(&app_base_url, &song_queue_id, &user_id).await {
|
||||||
Ok((
|
Ok((
|
||||||
_song,
|
_song,
|
||||||
_coverart,
|
_coverart,
|
||||||
(song_queue_id, song_queue_path),
|
(song_queue_id, song_queue_path),
|
||||||
(coverart_queue_id, coverart_queue_path),
|
(coverart_queue_id, coverart_queue_path),
|
||||||
)) => {
|
)) => {
|
||||||
// TODO: Wipe data from song and coverart queues
|
|
||||||
match wipe_data_from_queues(
|
match wipe_data_from_queues(
|
||||||
&app_base_url,
|
&app_base_url,
|
||||||
&song_queue_id,
|
&song_queue_id,
|
||||||
@@ -39,7 +39,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
// TODO: Cleanup files in local filesystem
|
match cleanup(&song_queue_path, &coverart_queue_path).await {
|
||||||
|
Ok(_) => {
|
||||||
|
println!("Successful cleanup");
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
eprintln!("Error: {err:?}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("Error: {err:?}");
|
eprintln!("Error: {err:?}");
|
||||||
@@ -99,6 +106,23 @@ async fn wipe_data_from_queues(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn cleanup(
|
||||||
|
song_queue_path: &String,
|
||||||
|
coverart_queue_path: &String,
|
||||||
|
) -> Result<(), std::io::Error> {
|
||||||
|
match the_rest::cleanup::clean_song_queue(song_queue_path) {
|
||||||
|
Ok(_) => {}
|
||||||
|
Err(err) => {
|
||||||
|
eprintln!("Error: Problem cleaning up SongQueue files {err:?}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
match the_rest::cleanup::clean_coverart_queue(coverart_queue_path) {
|
||||||
|
Ok(_) => Ok(()),
|
||||||
|
Err(err) => Err(err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async fn is_queue_empty(
|
async fn is_queue_empty(
|
||||||
api_url: &String,
|
api_url: &String,
|
||||||
) -> Result<(bool, responses::fetch_next_queue_item::SongQueueItem), reqwest::Error> {
|
) -> Result<(bool, responses::fetch_next_queue_item::SongQueueItem), reqwest::Error> {
|
||||||
@@ -125,6 +149,7 @@ async fn is_queue_empty(
|
|||||||
async fn some_work(
|
async fn some_work(
|
||||||
app_base_url: &String,
|
app_base_url: &String,
|
||||||
song_queue_id: &uuid::Uuid,
|
song_queue_id: &uuid::Uuid,
|
||||||
|
user_id: &uuid::Uuid,
|
||||||
) -> Result<
|
) -> Result<
|
||||||
(
|
(
|
||||||
icarus_models::song::Song,
|
icarus_models::song::Song,
|
||||||
@@ -153,16 +178,13 @@ async fn some_work(
|
|||||||
Ok(_inner_response) => {
|
Ok(_inner_response) => {
|
||||||
println!("Response: {_inner_response:?}");
|
println!("Response: {_inner_response:?}");
|
||||||
|
|
||||||
// TODO: Do not hard code this. Check if one of the existing
|
|
||||||
// endpoints already have the user_id
|
|
||||||
let user_id = uuid::Uuid::new_v4();
|
|
||||||
// TODO: Place this somewhere else
|
// TODO: Place this somewhere else
|
||||||
let song_type = String::from("flac");
|
let song_type = String::from("flac");
|
||||||
// Err(std::io::Error::other(err.to_string()))
|
|
||||||
match the_rest::create_song::create(
|
match the_rest::create_song::create(
|
||||||
app_base_url,
|
app_base_url,
|
||||||
&metadata,
|
&metadata,
|
||||||
&user_id,
|
user_id,
|
||||||
&song_type,
|
&song_type,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
@@ -6,6 +6,7 @@ pub mod fetch_next_queue_item {
|
|||||||
pub id: uuid::Uuid,
|
pub id: uuid::Uuid,
|
||||||
pub filename: String,
|
pub filename: String,
|
||||||
pub status: String,
|
pub status: String,
|
||||||
|
pub user_id: uuid::Uuid,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
@@ -98,7 +98,6 @@ pub mod wipe_data {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: Wipe data from queued coverart
|
|
||||||
pub mod coverart_queue {
|
pub mod coverart_queue {
|
||||||
pub async fn wipe_data(
|
pub async fn wipe_data(
|
||||||
base_url: &String,
|
base_url: &String,
|
||||||
@@ -123,3 +122,54 @@ pub mod wipe_data {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub mod cleanup {
|
||||||
|
pub fn clean_song_queue(song_queue_path: &String) -> Result<(), std::io::Error> {
|
||||||
|
let file_path = std::path::Path::new(song_queue_path);
|
||||||
|
if file_path.exists() {
|
||||||
|
match std::fs::remove_file(file_path) {
|
||||||
|
Ok(_) => {
|
||||||
|
if check_file_existence(song_queue_path) {
|
||||||
|
Err(std::io::Error::other(String::from(
|
||||||
|
"SongQueue file exists after a deletion",
|
||||||
|
)))
|
||||||
|
} else {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Err(std::io::Error::other(String::from(
|
||||||
|
"SongQueue file path does not exists",
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn clean_coverart_queue(coverart_queue_path: &String) -> Result<(), std::io::Error> {
|
||||||
|
let coverart_file_path = std::path::Path::new(coverart_queue_path);
|
||||||
|
if coverart_file_path.exists() {
|
||||||
|
match std::fs::remove_file(coverart_file_path) {
|
||||||
|
Ok(_) => {
|
||||||
|
if !check_file_existence(coverart_queue_path) {
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
Err(std::io::Error::other(String::from(
|
||||||
|
"CoverArt file stil exists",
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Err(std::io::Error::other(String::from(
|
||||||
|
"CoverArt file does not exists",
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn check_file_existence(file_path: &String) -> bool {
|
||||||
|
let path = std::path::Path::new(file_path);
|
||||||
|
path.exists()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user