mirror of
https://github.com/agersant/polaris
synced 2024-12-04 02:29:11 +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 password;
|
||||||
{
|
{
|
||||||
let input = request.get_ref::<params::Params>().unwrap();
|
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(),
|
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(),
|
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 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,
|
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() {
|
let playlist_name = match percent_decode(playlist_name.as_bytes()).decode_utf8() {
|
||||||
Ok(s) => s,
|
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)?;
|
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 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,
|
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() {
|
let playlist_name = match percent_decode(playlist_name.as_bytes()).decode_utf8() {
|
||||||
Ok(s) => s,
|
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)?;
|
playlist::delete_playlist(&playlist_name, &username, db)?;
|
||||||
|
|
|
@ -31,7 +31,6 @@ pub struct User {
|
||||||
pub struct Playlist {
|
pub struct Playlist {
|
||||||
id: i32,
|
id: i32,
|
||||||
owner: i32,
|
owner: i32,
|
||||||
name: String,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Identifiable, Queryable, Associations)]
|
#[derive(Identifiable, Queryable, Associations)]
|
||||||
|
@ -39,8 +38,6 @@ pub struct Playlist {
|
||||||
pub struct PlaylistSong {
|
pub struct PlaylistSong {
|
||||||
id: i32,
|
id: i32,
|
||||||
playlist: i32,
|
playlist: i32,
|
||||||
path: String,
|
|
||||||
ordering: i32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Insertable)]
|
#[derive(Insertable)]
|
||||||
|
@ -111,6 +108,7 @@ pub fn save_playlist<T>(playlist_name: &str,
|
||||||
{
|
{
|
||||||
use self::playlists::dsl::*;
|
use self::playlists::dsl::*;
|
||||||
playlist = playlists
|
playlist = playlists
|
||||||
|
.select((id, owner))
|
||||||
.filter(name.eq(playlist_name).and(owner.eq(user.id)))
|
.filter(name.eq(playlist_name).and(owner.eq(user.id)))
|
||||||
.get_result(connection.deref())?;
|
.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::*;
|
use self::playlists::dsl::*;
|
||||||
playlist = playlists
|
playlist = playlists
|
||||||
|
.select((id, owner))
|
||||||
.filter(name.eq(playlist_name).and(owner.eq(user.id)))
|
.filter(name.eq(playlist_name).and(owner.eq(user.id)))
|
||||||
.get_result(connection.deref())?;
|
.get_result(connection.deref())?;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue