More cleanup
This commit is contained in:
@@ -195,7 +195,7 @@ impl CommitManager {
|
|||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("Error generating song filename: {err:?}");
|
eprintln!("Error generating song filename: {err:?}");
|
||||||
utilities::checks::exit_program(-3);
|
utilities::checks::exit_program(-3);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
match song.save_to_filesystem() {
|
match song.save_to_filesystem() {
|
||||||
@@ -436,17 +436,11 @@ impl CommitManager {
|
|||||||
println!("Queued status updated");
|
println!("Queued status updated");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||||
Err(std::io::Error::other(err.to_string()))
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
Err(err) => {
|
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||||
Err(std::io::Error::other(err.to_string()))
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
Err(err) => {
|
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||||
Err(std::io::Error::other(err.to_string()))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -490,7 +484,7 @@ impl CommitManager {
|
|||||||
}
|
}
|
||||||
Ok(songs)
|
Ok(songs)
|
||||||
}
|
}
|
||||||
Err(_) => Err(std::io::Error::other("Songs not retrieved"))
|
Err(_) => Err(std::io::Error::other("Songs not retrieved")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -571,7 +565,9 @@ impl CommitManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Err(std::io::Error::other("CoverArt directory and filename not found"))
|
Err(std::io::Error::other(
|
||||||
|
"CoverArt directory and filename not found",
|
||||||
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_file_extension(&self, file_name: &std::ffi::OsString) -> En {
|
fn find_file_extension(&self, file_name: &std::ffi::OsString) -> En {
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ impl Default for TokenManager {
|
|||||||
user: icarus_models::user::User::default(),
|
user: icarus_models::user::User::default(),
|
||||||
api: models::api::Api::default(),
|
api: models::api::Api::default(),
|
||||||
};
|
};
|
||||||
|
|
||||||
token.init();
|
token.init();
|
||||||
|
|
||||||
token
|
token
|
||||||
@@ -35,7 +34,6 @@ impl TokenManager {
|
|||||||
println!("Sending request for a token");
|
println!("Sending request for a token");
|
||||||
|
|
||||||
let url = self.retrieve_url();
|
let url = self.retrieve_url();
|
||||||
|
|
||||||
println!("URL: {url}");
|
println!("URL: {url}");
|
||||||
|
|
||||||
let mut token = icarus_models::token::AccessToken {
|
let mut token = icarus_models::token::AccessToken {
|
||||||
@@ -62,19 +60,18 @@ impl TokenManager {
|
|||||||
token.token_type = login_result.token_type.clone();
|
token.token_type = login_result.token_type.clone();
|
||||||
token.expiration = login_result.expiration;
|
token.expiration = login_result.expiration;
|
||||||
token.message = response.message;
|
token.message = response.message;
|
||||||
|
Ok(token)
|
||||||
|
}
|
||||||
|
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||||
}
|
}
|
||||||
Err(_) => println!("Hm, the response didn't match the shape we expected."),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
reqwest::StatusCode::UNAUTHORIZED => {
|
reqwest::StatusCode::UNAUTHORIZED => {
|
||||||
println!("Need to grab a new token");
|
Err(std::io::Error::other("Need to grab a new token"))
|
||||||
}
|
}
|
||||||
other => {
|
other => {
|
||||||
panic!("Uh oh! Something unexpected happened: {other:?}");
|
panic!("Uh oh! Something unexpected happened: {other:?}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(token)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init(&mut self) {
|
pub fn init(&mut self) {
|
||||||
@@ -84,10 +81,6 @@ impl TokenManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn retrieve_url(&self) -> String {
|
pub fn retrieve_url(&self) -> String {
|
||||||
let api = &self.api;
|
format!("{}{}", self.api.url, self.api.endpoint)
|
||||||
let mut url = String::from(&api.url);
|
|
||||||
url += &String::from(&api.endpoint);
|
|
||||||
|
|
||||||
url
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user