Saving changes
This commit is contained in:
@@ -152,7 +152,8 @@ impl CommitManager {
|
|||||||
let value = &arg.value;
|
let value = &arg.value;
|
||||||
|
|
||||||
if flag == "-D" {
|
if flag == "-D" {
|
||||||
song.id = value.parse::<i32>().unwrap();
|
song.id = uuid::Uuid::from_str(value.as_str()).unwrap();
|
||||||
|
// value.parse::<i32>().unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,7 +176,7 @@ impl CommitManager {
|
|||||||
fn download_song(&self) {
|
fn download_song(&self) {
|
||||||
println!("Deleting song");
|
println!("Deleting song");
|
||||||
let dwn = self.ica_action.retrieve_flag_value(&String::from("-b"));
|
let dwn = self.ica_action.retrieve_flag_value(&String::from("-b"));
|
||||||
let id: i32 = dwn.parse::<i32>().unwrap();
|
let id = uuid::Uuid::from_str(dwn.as_str()).unwrap();
|
||||||
|
|
||||||
let mut prsr = parsers::api_parser::APIParser {
|
let mut prsr = parsers::api_parser::APIParser {
|
||||||
api: models::api::API::default(),
|
api: models::api::API::default(),
|
||||||
@@ -337,7 +338,7 @@ impl CommitManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut cover_art = icarus_models::coverart::CoverArt {
|
let mut cover_art = icarus_models::coverart::CoverArt {
|
||||||
id: 0,
|
id: uuid::Uuid::nil(),
|
||||||
title: String::new(),
|
title: String::new(),
|
||||||
path: cover_path.clone(),
|
path: cover_path.clone(),
|
||||||
data: Vec::new(),
|
data: Vec::new(),
|
||||||
@@ -430,7 +431,7 @@ impl CommitManager {
|
|||||||
};
|
};
|
||||||
|
|
||||||
songs.push(icarus_models::song::Song {
|
songs.push(icarus_models::song::Song {
|
||||||
id: -1,
|
id: uuid::Uuid::nil(),
|
||||||
title: track.title.clone(),
|
title: track.title.clone(),
|
||||||
artist: track.artist.clone(),
|
artist: track.artist.clone(),
|
||||||
disc: track.disc.clone(),
|
disc: track.disc.clone(),
|
||||||
@@ -471,15 +472,8 @@ impl CommitManager {
|
|||||||
panic!("Directory does not exist");
|
panic!("Directory does not exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut cover_art = icarus_models::coverart::CoverArt {
|
let mut cover_art =
|
||||||
id: 0,
|
icarus_models::coverart::init::init_coverart_only_path(sourcepath.clone());
|
||||||
title: String::new(),
|
|
||||||
path: match self.get_cover_art_path(&sourcepath) {
|
|
||||||
Ok(o) => o,
|
|
||||||
Err(_) => String::new(),
|
|
||||||
},
|
|
||||||
data: Vec::new(),
|
|
||||||
};
|
|
||||||
let metadatapath = match self.get_metadata_path(&sourcepath) {
|
let metadatapath = match self.get_metadata_path(&sourcepath) {
|
||||||
Ok(o) => o,
|
Ok(o) => o,
|
||||||
Err(_) => String::new(),
|
Err(_) => String::new(),
|
||||||
@@ -565,30 +559,6 @@ impl CommitManager {
|
|||||||
return En::Other;
|
return En::Other;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_cover_art_path(&self, directory_path: &String) -> Result<String> {
|
|
||||||
for entry in read_dir(std::path::Path::new(directory_path))? {
|
|
||||||
let entry = entry?;
|
|
||||||
|
|
||||||
let file_type = entry.file_type();
|
|
||||||
let file_name = entry.file_name();
|
|
||||||
|
|
||||||
println!("file type: {:?}", file_type);
|
|
||||||
println!("file name: {:?}", file_name);
|
|
||||||
|
|
||||||
match self.find_file_extension(&file_name) {
|
|
||||||
En::ImageFile => {
|
|
||||||
let directory_part = directory_path.clone();
|
|
||||||
let fname = utilities::string::o_to_string(&file_name);
|
|
||||||
let fullpath = directory_part + "/" + &fname.unwrap();
|
|
||||||
return Ok(fullpath);
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(String::new())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_metadata_path(&self, directory_path: &String) -> Result<String> {
|
fn get_metadata_path(&self, directory_path: &String) -> Result<String> {
|
||||||
for entry in read_dir(std::path::Path::new(directory_path))? {
|
for entry in read_dir(std::path::Path::new(directory_path))? {
|
||||||
let entry = entry?;
|
let entry = entry?;
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ impl TokenManager {
|
|||||||
println!("URL: {}", url);
|
println!("URL: {}", url);
|
||||||
|
|
||||||
let mut token = icarus_models::token::AccessToken {
|
let mut token = icarus_models::token::AccessToken {
|
||||||
user_id: -1,
|
user_id: uuid::Uuid::nil(),
|
||||||
username: String::new(),
|
username: String::new(),
|
||||||
token: String::new(),
|
token: String::new(),
|
||||||
token_type: String::new(),
|
token_type: String::new(),
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::models;
|
use crate::models;
|
||||||
|
|
||||||
pub fn retrieve_url(api: &models::api::API, with_id: bool, id: i32) -> String {
|
pub fn retrieve_url(api: &models::api::API, with_id: bool, id: &uuid::Uuid) -> String {
|
||||||
if with_id {
|
if with_id {
|
||||||
retrieve_url_with_id(&api, id)
|
retrieve_url_with_id(&api, id)
|
||||||
} else {
|
} else {
|
||||||
@@ -19,7 +19,7 @@ fn retrieve_url_reg(api: &models::api::API) -> String {
|
|||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn retrieve_url_with_id(api: &models::api::API, id: i32) -> String {
|
fn retrieve_url_with_id(api: &models::api::API, id: &uuid::Uuid) -> String {
|
||||||
let mut url: String = String::from(&api.url);
|
let mut url: String = String::from(&api.url);
|
||||||
url += &String::from("api/");
|
url += &String::from("api/");
|
||||||
url += &String::from(&api.version);
|
url += &String::from(&api.version);
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ impl Delete {
|
|||||||
song: &icarus_models::song::Song,
|
song: &icarus_models::song::Song,
|
||||||
) -> Result<icarus_models::song::Song, std::io::Error> {
|
) -> Result<icarus_models::song::Song, std::io::Error> {
|
||||||
self.api.endpoint = "song/data/delete".to_owned();
|
self.api.endpoint = "song/data/delete".to_owned();
|
||||||
let url = syncers::common::retrieve_url(&self.api, true, song.id);
|
let url = syncers::common::retrieve_url(&self.api, true, &song.id);
|
||||||
let client = reqwest::Client::builder().build().unwrap();
|
let client = reqwest::Client::builder().build().unwrap();
|
||||||
let access_token = token.bearer_token();
|
let access_token = token.bearer_token();
|
||||||
let response = client
|
let response = client
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ impl Download {
|
|||||||
song: &icarus_models::song::Song,
|
song: &icarus_models::song::Song,
|
||||||
) -> Result<String, MyError> {
|
) -> Result<String, MyError> {
|
||||||
self.api.endpoint = String::from("song/data/download");
|
self.api.endpoint = String::from("song/data/download");
|
||||||
let url = syncers::common::retrieve_url(&self.api, true, song.id);
|
let url = syncers::common::retrieve_url(&self.api, true, &song.id);
|
||||||
let access_token = token.bearer_token();
|
let access_token = token.bearer_token();
|
||||||
|
|
||||||
let client = reqwest::Client::builder().build().unwrap();
|
let client = reqwest::Client::builder().build().unwrap();
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ impl RetrieveRecords {
|
|||||||
token: &icarus_models::token::AccessToken,
|
token: &icarus_models::token::AccessToken,
|
||||||
) -> Result<Vec<icarus_models::song::Song>, Error> {
|
) -> Result<Vec<icarus_models::song::Song>, Error> {
|
||||||
self.api.endpoint = String::from("song");
|
self.api.endpoint = String::from("song");
|
||||||
let url = syncers::common::retrieve_url(&self.api, false, 0);
|
let url = syncers::common::retrieve_url(&self.api, false, &uuid::Uuid::nil());
|
||||||
let access_token = token.bearer_token();
|
let access_token = token.bearer_token();
|
||||||
|
|
||||||
let client = reqwest::Client::builder().build().unwrap();
|
let client = reqwest::Client::builder().build().unwrap();
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ impl Upload {
|
|||||||
cover: &icarus_models::coverart::CoverArt,
|
cover: &icarus_models::coverart::CoverArt,
|
||||||
) -> Result<reqwest::Response, reqwest::Error> {
|
) -> Result<reqwest::Response, reqwest::Error> {
|
||||||
self.api.endpoint = String::from("song/data/upload/with/data");
|
self.api.endpoint = String::from("song/data/upload/with/data");
|
||||||
let url = syncers::common::retrieve_url(&self.api, false, 0);
|
let url = syncers::common::retrieve_url(&self.api, false, &uuid::Uuid::new_v4());
|
||||||
let access_token = token.bearer_token();
|
let access_token = token.bearer_token();
|
||||||
|
|
||||||
if url.is_empty() {
|
if url.is_empty() {
|
||||||
|
|||||||
Reference in New Issue
Block a user