Update dependencies (#53)

* Removing new lines

* Updated reqwest, tokio, tokio-utils, and uuid

* Including Cargo.lock in source control

* Not sure how this got here

* Updated icarus_models

* Workflow change

* Removing unused workflow

* Github workflow fix

* Warning fixes

* Fixed what caused failed test

* Code cleanup and formatting
This commit was merged in pull request #53.
This commit is contained in:
KD
2025-07-02 12:26:38 -04:00
committed by GitHub
parent 8e6ddbc9df
commit 8b2b2f82e9
15 changed files with 1884 additions and 158 deletions
-22
View File
@@ -1,22 +0,0 @@
name: Rust
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
+1 -1
View File
@@ -4,7 +4,7 @@ on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
branches: [ "master", "icarus_v2_support" ]
env:
CARGO_TERM_COLOR: always
-1
View File
@@ -7,4 +7,3 @@
/target
.vscode/
Cargo.lock
View File
Generated
+1834
View File
File diff suppressed because it is too large Load Diff
+5 -9
View File
@@ -4,18 +4,14 @@ version = "0.6.0"
rust-version = "1.88"
edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
futures = { version = "0.3.31" }
http = { version = "1.3.1" }
reqwest = { version = "0.12.15", features = ["json", "blocking", "multipart", "stream"] }
reqwest = { version = "0.12.20", features = ["json", "blocking", "multipart", "stream"] }
serde = { version = "1.0.219", features = ["derive"] }
serde_json = "1.0.140"
tokio = { version = "1.44.1", features = ["full"] }
tokio-util = { version = "0.7.14", features = ["codec"] }
uuid = { version = "1.16.0", features = ["v4", "serde"] }
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.4.3" }
tokio = { version = "1.45.1", features = ["full"] }
tokio-util = { version = "0.7.15", features = ["codec"] }
uuid = { version = "1.17.0", features = ["v4", "serde"] }
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.5.0-devel-7958b89abc-111" }
+1 -1
View File
@@ -32,5 +32,5 @@ pub fn print_help() {
-D song id"#,
);
println!("{}", msg);
println!("{msg}");
}
+2 -2
View File
@@ -16,7 +16,7 @@ fn main() {
utilities::checks::exit_program(-1);
}
println!("Argument count: {}", args_len);
println!("Argument count: {args_len}");
let mut act_mgr = managers::action_managers::ActionManager::default();
act_mgr.set_params(&args);
@@ -41,7 +41,7 @@ mod tests {
let meta_path = String::from("tests/sample2_tracks/album.json");
if !std::path::Path::new(&meta_path).exists() {
assert!(false, "File does not exists: {:?}", meta_path);
assert!(false, "File does not exists: {meta_path:?}");
}
match icarus_models::album::collection::parse_album(&meta_path) {
+6 -18
View File
@@ -2,32 +2,20 @@ use crate::models;
pub fn retrieve_url(api: &models::api::API, with_id: bool, id: &uuid::Uuid) -> String {
if with_id {
retrieve_url_with_id(&api, id)
retrieve_url_with_id(api, id)
} else {
retrieve_url_reg(&api)
retrieve_url_reg(api)
}
}
fn retrieve_url_reg(api: &models::api::API) -> String {
let mut url: String = String::from(&api.url);
url += &String::from("/");
url += &String::from("api/");
url += &String::from(&api.version);
url += &String::from("/");
url += &String::from(&api.endpoint);
url += &String::from("/");
let url = format!("{}/api/{}/{}/", api.url, api.version, api.endpoint);
return url;
url
}
fn retrieve_url_with_id(api: &models::api::API, id: &uuid::Uuid) -> String {
let mut url: String = String::from(&api.url);
url += &String::from("api/");
url += &String::from(&api.version);
url += &String::from("/");
url += &String::from(&api.endpoint);
url += &String::from("/");
url += &id.to_string();
let url = format!("{}/api/{}/{}/{}", api.url, api.version, api.endpoint, id);
return url;
url
}
+3 -17
View File
@@ -5,19 +5,11 @@ use reqwest;
use crate::models;
use crate::syncers;
#[derive(Clone, Debug)]
#[derive(Clone, Debug, Default)]
pub struct Delete {
pub api: models::api::API,
}
impl Default for Delete {
fn default() -> Self {
Delete {
api: models::api::API::default(),
}
}
}
impl Delete {
pub async fn delete_song(
&mut self,
@@ -41,16 +33,10 @@ impl Delete {
match response.json::<icarus_models::song::Song>().await {
Ok(sng) => Ok(sng),
Err(er) => Err(std::io::Error::new(
std::io::ErrorKind::Other,
er.to_string(),
)),
Err(er) => Err(std::io::Error::other(er.to_string())),
}
}
other => Err(std::io::Error::new(
std::io::ErrorKind::Other,
other.to_string(),
)),
other => Err(std::io::Error::other(other.to_string())),
}
}
}
+7 -22
View File
@@ -3,18 +3,11 @@ use std::default::Default;
use crate::models;
use crate::syncers;
#[derive(Default)]
pub struct Download {
pub api: models::api::API,
}
impl Default for Download {
fn default() -> Self {
Download {
api: models::api::API::default(),
}
}
}
#[derive(Debug)]
pub enum MyError {
Request(reqwest::Error),
@@ -31,7 +24,7 @@ impl Download {
let url = syncers::common::retrieve_url(&self.api, true, &song.id);
let access_token = token.bearer_token();
println!("Url: {:?}", url);
println!("Url: {url:?}");
let client = reqwest::Client::builder().build().unwrap();
@@ -45,24 +38,16 @@ impl Download {
reqwest::StatusCode::OK => {
let data = rep.text();
match data.await {
Ok(e) => {
return Ok(e);
}
Err(er) => {
return Err(MyError::Other(er.to_string()));
}
Ok(e) => Ok(e),
Err(er) => Err(MyError::Other(er.to_string())),
}
}
reqwest::StatusCode::UNAUTHORIZED => {
return Err(MyError::Other(String::from("Need to grab a new token")));
}
other => {
return Err(MyError::Other(other.to_string()));
Err(MyError::Other(String::from("Need to grab a new token")))
}
other => Err(MyError::Other(other.to_string())),
},
Err(er) => {
return Err(MyError::Request(er));
}
Err(er) => Err(MyError::Request(er)),
}
}
}
+4 -24
View File
@@ -4,18 +4,11 @@ use std::io::Error;
use crate::models;
use crate::syncers;
#[derive(Default)]
pub struct RetrieveRecords {
pub api: models::api::API,
}
impl Default for RetrieveRecords {
fn default() -> Self {
RetrieveRecords {
api: models::api::API::default(),
}
}
}
impl RetrieveRecords {
pub async fn get_all_songs(
&mut self,
@@ -38,26 +31,13 @@ impl RetrieveRecords {
// on success, parse our JSON to an APIResponse
match response.json::<Vec<icarus_models::song::Song>>().await {
Ok(parsed) => Ok(parsed),
Err(err) => {
return Err(std::io::Error::new(
std::io::ErrorKind::Other,
err.to_string(),
));
}
Err(err) => Err(std::io::Error::other(err.to_string())),
}
}
reqwest::StatusCode::UNAUTHORIZED => {
return Err(std::io::Error::new(
std::io::ErrorKind::Other,
"Need to grab a new token",
));
}
other => {
return Err(std::io::Error::new(
std::io::ErrorKind::Other,
other.to_string(),
));
Err(std::io::Error::other("Need to grab a new token"))
}
other => Err(std::io::Error::other(other.to_string())),
}
}
}
+18 -35
View File
@@ -6,18 +6,11 @@ use reqwest;
use crate::models;
use crate::syncers;
#[derive(Default)]
pub struct Upload {
pub api: models::api::API,
}
impl Default for Upload {
fn default() -> Self {
Upload {
api: models::api::API::default(),
}
}
}
impl Upload {
pub async fn upload_song_with_metadata(
&mut self,
@@ -33,8 +26,8 @@ impl Upload {
println!("Url is empty");
}
println!("Url: {}", url);
println!("Token: {}", access_token);
println!("Url: {url}");
println!("Token: {access_token}");
println!("Path: {:?}", song.song_path());
let mut headers = reqwest::header::HeaderMap::new();
@@ -44,7 +37,7 @@ impl Upload {
);
headers.insert(reqwest::header::ACCEPT, HeaderValue::from_static("*/*"));
let form = self.init_form(&song, &cover);
let form = self.init_form(song, cover);
let client = reqwest::Client::builder().build().unwrap();
match client
.post(url)
@@ -53,12 +46,8 @@ impl Upload {
.send()
.await
{
Ok(r) => {
return Ok(r);
}
Err(err) => {
return Err(err);
}
Ok(r) => Ok(r),
Err(err) => Err(err),
}
}
@@ -67,25 +56,19 @@ impl Upload {
song: &icarus_models::song::Song,
cover: &icarus_models::coverart::CoverArt,
) -> reqwest::multipart::Form {
let songpath = match song.song_path() {
Ok(s) => s,
Err(_) => String::new(),
};
let songpath = song.song_path().unwrap_or_default();
let coverpath = cover.path.clone();
println!("Cover path: {:?}", coverpath);
let song_detail = match song.to_metadata_json(true) {
Ok(s) => s,
Err(_) => String::new(),
};
println!("Cover path: {coverpath:?}");
let song_detail = song.to_metadata_json(true).unwrap_or_default();
println!("\n{}\n", song_detail);
println!("\n{song_detail}\n");
let mut song_filename = String::from("audio");
song_filename += icarus_models::constants::file_extensions::audio::DEFAULTMUSICEXTENSION;
let mut cover_filename = String::from("cover");
cover_filename += icarus_models::constants::file_extensions::image::JPGEXTENSION;
let form = reqwest::multipart::Form::new()
reqwest::multipart::Form::new()
.part(
"file",
reqwest::multipart::Part::bytes(std::fs::read(songpath).unwrap())
@@ -96,15 +79,15 @@ impl Upload {
reqwest::multipart::Part::bytes(std::fs::read(coverpath).unwrap())
.file_name(cover_filename),
)
.text("metadata", song_detail);
return form;
.text("metadata", song_detail)
}
pub fn set_api(&mut self, host: &String) {
let mut api = models::api::API::default();
api.url = host.clone();
api.version = String::from("v1");
pub fn set_api(&mut self, host: &str) {
let api = models::api::API {
url: host.to_owned(),
version: String::from("v1"),
endpoint: String::new(),
};
self.api = api;
}
}
+2 -2
View File
@@ -4,11 +4,11 @@ use serde::{Deserialize, Serialize};
pub struct Checks {}
impl Checks {
pub fn _is_numeric(text: &String) -> bool {
pub fn _is_numeric(text: &str) -> bool {
text.parse::<f64>().is_ok()
}
pub fn _index_of_item_in_container<F>(container: &String, item: &char, func: F) -> i32
pub fn _index_of_item_in_container<F>(container: &str, item: &char, func: F) -> i32
where
F: Fn(&char, &char) -> bool,
{
+1 -4
View File
@@ -1,9 +1,6 @@
pub fn o_to_string(val: &std::ffi::OsString) -> Result<std::string::String, std::io::Error> {
match val.clone().into_string() {
Ok(value) => Ok(value),
Err(_) => Err(std::io::Error::new(
std::io::ErrorKind::Other,
String::from("Error"),
)),
Err(_) => Err(std::io::Error::other(String::from("Error"))),
}
}