diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/database.rs | 6 | ||||
-rw-r--r-- | src/errors.rs | 5 | ||||
-rw-r--r-- | src/main.rs | 3 | ||||
-rw-r--r-- | src/spotify.rs | 4 |
4 files changed, 6 insertions, 12 deletions
diff --git a/src/database.rs b/src/database.rs index e7b6f7f..bf986c7 100644 --- a/src/database.rs +++ b/src/database.rs @@ -61,14 +61,14 @@ pub async fn insert_track(user_id: i32, track: FullTrack, weight: i32) -> Result println!("{:#?}", track); return Err("failed to load get track information".into()); } - print!(" {} ", track.id.clone()?); + print!(" {} ", track.id.clone().unwrap()); client .execute( "INSERT INTO track (track_code, name, artist, popularity) VALUES ($1, $2, $3, $4) ON CONFLICT DO NOTHING", &[ - &(track.id.clone()?), + &(track.id.clone().unwrap()), &track.name, &track.artists[0].name, &(track.popularity as i32), @@ -78,7 +78,7 @@ pub async fn insert_track(user_id: i32, track: FullTrack, weight: i32) -> Result let track_id: i32 = client .query( "SELECT track_id FROM track where track_code = $1;", - &[&(track.id?)], + &[&(track.id.unwrap())], ) .await?[0] .get(0); diff --git a/src/errors.rs b/src/errors.rs index 51ac8fd..4217939 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -44,11 +44,6 @@ impl<'a> From<PoisonError<MutexGuard<'a, tokio_postgres::Client>>> for Error { Error::Misc(format!("failed to lock the client mutex: {:?}", error)) } } -impl<'a> From<std::option::NoneError> for Error { - fn from(error: std::option::NoneError) -> Self { - Error::Misc(format!("tried to unwrap none at: {:?}", error)) - } -} impl<'a> Responder<'a, 'a> for Error { fn respond_to(self, _: &Request) -> response::Result<'a> { let response = match self { diff --git a/src/main.rs b/src/main.rs index 0ff4827..b297f14 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,3 @@ -#![feature(proc_macro_hygiene, decl_macro)] -#![feature(try_trait)] - #[macro_use] extern crate rocket; #[macro_use] diff --git a/src/spotify.rs b/src/spotify.rs index 04a82bc..5d2dc8c 100644 --- a/src/spotify.rs +++ b/src/spotify.rs @@ -116,7 +116,9 @@ fn generate_random_uuid(length: usize) -> String { pub async fn auth_user(name: &str, code: &str) -> Result<(String, Spotify), Error> { let (user, mut spotify) = { let mut guard = (*CACHE).lock()?; - guard.remove(name)? + guard + .remove(name) + .ok_or(Error::Misc("failed to remove user from waitlist".into()))? }; println!("auth: {:?} url: {}", name, code); spotify.request_user_token(code).await?; |