mirror of
https://github.com/agersant/polaris
synced 2024-12-11 13:56:24 +00:00
Fixed compiler warnings
This commit is contained in:
parent
6ae9f6b6a0
commit
ce4f9ef87f
2 changed files with 12 additions and 13 deletions
20
src/api.rs
20
src/api.rs
|
@ -340,13 +340,13 @@ fn auth(request: &mut Request, db: &DB) -> IronResult<Response> {
|
|||
let password;
|
||||
{
|
||||
let input = request.get_ref::<params::Params>().unwrap();
|
||||
username = match input.find(&["username"]) {
|
||||
username = match input.find(&["username"]) {
|
||||
Some(¶ms::Value::String(ref username)) => username.clone(),
|
||||
_ => return Err(Error::from(ErrorKind::MissingUsername).into()),
|
||||
_ => return Err(Error::from(ErrorKind::MissingUsername).into()),
|
||||
};
|
||||
password = match input.find(&["password"]) {
|
||||
password = match input.find(&["password"]) {
|
||||
Some(¶ms::Value::String(ref password)) => password.clone(),
|
||||
_ => return Err(Error::from(ErrorKind::MissingPassword).into()),
|
||||
_ => return Err(Error::from(ErrorKind::MissingPassword).into()),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -568,14 +568,14 @@ fn read_playlist(request: &mut Request, db: &DB) -> IronResult<Response> {
|
|||
};
|
||||
|
||||
let params = request.extensions.get::<Router>().unwrap();
|
||||
let ref playlist_name = match params.find("playlist_name") {
|
||||
let ref playlist_name = match params.find("playlist_name") {
|
||||
Some(s) => s,
|
||||
_ => return Err(Error::from(ErrorKind::MissingPlaylistName).into()),
|
||||
_ => return Err(Error::from(ErrorKind::MissingPlaylistName).into()),
|
||||
};
|
||||
|
||||
let playlist_name = match percent_decode(playlist_name.as_bytes()).decode_utf8() {
|
||||
Ok(s) => s,
|
||||
Err(e) => return Err(Error::from(ErrorKind::EncodingError).into()),
|
||||
Err(_) => return Err(Error::from(ErrorKind::EncodingError).into()),
|
||||
};
|
||||
|
||||
let songs = playlist::read_playlist(&playlist_name, &username, db)?;
|
||||
|
@ -595,14 +595,14 @@ fn delete_playlist(request: &mut Request, db: &DB) -> IronResult<Response> {
|
|||
};
|
||||
|
||||
let params = request.extensions.get::<Router>().unwrap();
|
||||
let ref playlist_name = match params.find("playlist_name") {
|
||||
let ref playlist_name = match params.find("playlist_name") {
|
||||
Some(s) => s,
|
||||
_ => return Err(Error::from(ErrorKind::MissingPlaylistName).into()),
|
||||
_ => return Err(Error::from(ErrorKind::MissingPlaylistName).into()),
|
||||
};
|
||||
|
||||
let playlist_name = match percent_decode(playlist_name.as_bytes()).decode_utf8() {
|
||||
Ok(s) => s,
|
||||
Err(e) => return Err(Error::from(ErrorKind::EncodingError).into()),
|
||||
Err(_) => return Err(Error::from(ErrorKind::EncodingError).into()),
|
||||
};
|
||||
|
||||
playlist::delete_playlist(&playlist_name, &username, db)?;
|
||||
|
|
|
@ -31,7 +31,6 @@ pub struct User {
|
|||
pub struct Playlist {
|
||||
id: i32,
|
||||
owner: i32,
|
||||
name: String,
|
||||
}
|
||||
|
||||
#[derive(Identifiable, Queryable, Associations)]
|
||||
|
@ -39,8 +38,6 @@ pub struct Playlist {
|
|||
pub struct PlaylistSong {
|
||||
id: i32,
|
||||
playlist: i32,
|
||||
path: String,
|
||||
ordering: i32,
|
||||
}
|
||||
|
||||
#[derive(Insertable)]
|
||||
|
@ -111,6 +108,7 @@ pub fn save_playlist<T>(playlist_name: &str,
|
|||
{
|
||||
use self::playlists::dsl::*;
|
||||
playlist = playlists
|
||||
.select((id, owner))
|
||||
.filter(name.eq(playlist_name).and(owner.eq(user.id)))
|
||||
.get_result(connection.deref())?;
|
||||
}
|
||||
|
@ -176,6 +174,7 @@ pub fn read_playlist<T>(playlist_name: &str, owner: &str, db: &T) -> Result<Vec<
|
|||
{
|
||||
use self::playlists::dsl::*;
|
||||
playlist = playlists
|
||||
.select((id, owner))
|
||||
.filter(name.eq(playlist_name).and(owner.eq(user.id)))
|
||||
.get_result(connection.deref())?;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue