Compare commits
6 Commits
v0.2.3-dev
...
v0.2.4
Author | SHA1 | Date | |
---|---|---|---|
80762b81ae | |||
af4f1acb87 | |||
d5e24f9114 | |||
27e4b30d21 | |||
83eafd0005 | |||
e3895b6d1a |
@@ -3,7 +3,6 @@ name: Release Tagging
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- devel
|
||||
|
||||
jobs:
|
||||
@@ -50,6 +49,3 @@ jobs:
|
||||
release_name: Release ${{ steps.version.outputs.project_tag_release }}
|
||||
body: |
|
||||
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]]
|
||||
name = "songparser"
|
||||
version = "0.2.3"
|
||||
version = "0.2.4"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"icarus_envy",
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "songparser"
|
||||
version = "0.2.3"
|
||||
version = "0.2.4"
|
||||
edition = "2024"
|
||||
rust-version = "1.88"
|
||||
|
||||
|
27
src/main.rs
27
src/main.rs
@@ -31,7 +31,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
(song_queue_id, song_queue_path),
|
||||
(coverart_queue_id, coverart_queue_path),
|
||||
)) => {
|
||||
// TODO: Wipe data from song and coverart queues
|
||||
match wipe_data_from_queues(
|
||||
&app_base_url,
|
||||
&song_queue_id,
|
||||
@@ -40,7 +39,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.await
|
||||
{
|
||||
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) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
@@ -100,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(
|
||||
api_url: &String,
|
||||
) -> Result<(bool, responses::fetch_next_queue_item::SongQueueItem), reqwest::Error> {
|
||||
|
@@ -98,7 +98,6 @@ pub mod wipe_data {
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO: Wipe data from queued coverart
|
||||
pub mod coverart_queue {
|
||||
pub async fn wipe_data(
|
||||
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