cargo fmt

This commit is contained in:
kdeng00
2024-06-02 16:11:43 -04:00
parent ffc0d398f0
commit 9c3d5d67c5
3 changed files with 36 additions and 32 deletions
+14 -11
View File
@@ -21,7 +21,6 @@ pub struct CommitManager {
pub ica_action: models::icarus_action::IcarusAction, pub ica_action: models::icarus_action::IcarusAction,
} }
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
enum ActionValues { enum ActionValues {
DeleteAct, DeleteAct,
@@ -283,7 +282,7 @@ impl CommitManager {
song.filepath = Some(s.clone()); song.filepath = Some(s.clone());
song.directory = Some(sourcepath.clone()); song.directory = Some(sourcepath.clone());
self.initialize_disc_and_track(&mut song); self.initialize_disc_and_track(&mut song);
}, }
Err(er) => println!("Error: {:?}", er), Err(er) => println!("Error: {:?}", er),
} }
@@ -314,9 +313,13 @@ impl CommitManager {
Ok(()) Ok(())
} }
// Makes sure the elements in album.songs is populated // Makes sure the elements in album.songs is populated
fn song_parsing(&self, album: &mut models::song::Album, directory: &String, filenames: &Vec<String>) { fn song_parsing(
&self,
album: &mut models::song::Album,
directory: &String,
filenames: &Vec<String>,
) {
// Apply directory // Apply directory
for song in &mut album.songs { for song in &mut album.songs {
// let bor = song.as_mut(); // let bor = song.as_mut();
@@ -325,7 +328,7 @@ impl CommitManager {
Some(s) => println!("{}", s), Some(s) => println!("{}", s),
None => { None => {
song.directory = Some(directory.clone()); song.directory = Some(directory.clone());
}, }
} }
} }
@@ -339,24 +342,24 @@ impl CommitManager {
for song in &mut album.songs { for song in &mut album.songs {
match &mut song.album { match &mut song.album {
Some(_) => {}, Some(_) => {}
None => { None => {
song.album = Some(album.title.clone()); song.album = Some(album.title.clone());
}, }
} }
match &mut song.genre { match &mut song.genre {
Some(_) => {}, Some(_) => {}
None => { None => {
song.genre = Some(album.genre.clone()); song.genre = Some(album.genre.clone());
}, }
} }
match &mut song.year { match &mut song.year {
Some(_) => {}, Some(_) => {}
None => { None => {
song.year = Some(album.year.clone()); song.year = Some(album.year.clone());
}, }
} }
} }
} }
+4 -4
View File
@@ -93,7 +93,7 @@ impl Song {
pub fn to_data(&self) -> Result<Vec<u8>, std::io::Error> { pub fn to_data(&self) -> Result<Vec<u8>, std::io::Error> {
let path = self.song_path(); let path = self.song_path();
// let content = std::fs::read_to_string(path); // let content = std::fs::read_to_string(path);
let mut file = std::fs::File::open(path)?; let mut file = std::fs::File::open(path)?;
let mut buffer = Vec::new(); let mut buffer = Vec::new();
file.read(&mut buffer)?; file.read(&mut buffer)?;
Ok(buffer) Ok(buffer)
@@ -147,10 +147,10 @@ impl CoverArt {
match &self.path { match &self.path {
Some(val) => { Some(val) => {
path = String::from(val); path = String::from(val);
}, }
None => { None => {
(); ();
}, }
} }
let mut file = std::fs::File::open(path)?; let mut file = std::fs::File::open(path)?;
@@ -158,4 +158,4 @@ impl CoverArt {
file.read(&mut buffer)?; file.read(&mut buffer)?;
Ok(buffer) Ok(buffer)
} }
} }
+18 -17
View File
@@ -1,12 +1,12 @@
use std::default::Default; use std::default::Default;
use reqwest;
use reqwest::blocking::multipart; use reqwest::blocking::multipart;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use reqwest;
// use reqwest::blocking:: // use reqwest::blocking::
use reqwest::{Body, Client};
use reqwest::multipart::{Form, Part}; use reqwest::multipart::{Form, Part};
use reqwest::Response; use reqwest::Response;
use reqwest::{Body, Client};
use tokio::fs::File; use tokio::fs::File;
use crate::models; use crate::models;
@@ -15,7 +15,6 @@ pub struct Upload {
pub api: models::api::API, pub api: models::api::API,
} }
#[derive(Debug, Deserialize, Serialize)] #[derive(Debug, Deserialize, Serialize)]
struct Song { struct Song {
title: String, title: String,
@@ -62,20 +61,24 @@ impl Upload {
} }
// TODO: Implement // TODO: Implement
pub async fn upload_song_with_metadata(&mut self, token: &models::token::Token, song: &models::song::Song, pub async fn upload_song_with_metadata(
cover: &models::song::CoverArt, album: &models::song::Album) { &mut self,
self.api.endpoint = String::from("song/data/upload/with/data"); token: &models::token::Token,
let url = self.retrieve_url(&song); song: &models::song::Song,
let client = reqwest::Client::new(); cover: &models::song::CoverArt,
let new_song = self.initialize_song(&song, &album); album: &models::song::Album,
let access_token = token.bearer_token(); ) {
self.api.endpoint = String::from("song/data/upload/with/data");
let url = self.retrieve_url(&song);
let client = reqwest::Client::new();
let new_song = self.initialize_song(&song, &album);
let access_token = token.bearer_token();
let song_data = song.to_data(); let song_data = song.to_data();
let cover_data = cover.to_data(); let cover_data = cover.to_data();
match song_data { match song_data {
Ok(sd) => { Ok(sd) => {}
},
Err(er) => { Err(er) => {
println!("Error: {:?}", er); println!("Error: {:?}", er);
std::process::exit(-1); std::process::exit(-1);
@@ -83,7 +86,7 @@ impl Upload {
} }
match cover_data { match cover_data {
Ok(_) => {}, Ok(_) => {}
Err(er) => { Err(er) => {
println!("Error: {:?}", er); println!("Error: {:?}", er);
std::process::exit(-1); std::process::exit(-1);
@@ -111,7 +114,7 @@ impl Upload {
form = form.part("file", s_some_file) form = form.part("file", s_some_file)
.part("cover", c_data); .part("cover", c_data);
let response = client.post(url).multipart(form).send(); let response = client.post(url).multipart(form).send();
let result = response.text; let result = response.text;
@@ -119,8 +122,6 @@ impl Upload {
*/ */
} }
pub fn set_api(&mut self, host: &String) { pub fn set_api(&mut self, host: &String) {
let mut api = models::api::API::default(); let mut api = models::api::API::default();
api.url = host.clone(); api.url = host.clone();