Fixed a bug where playlists were overwriting each other

This commit is contained in:
Antoine Gersant 2017-09-24 20:20:37 -07:00
parent 7654d49246
commit e9010fd39d

View file

@ -74,7 +74,7 @@ pub fn list_playlists<T>(owner: &str, db: &T) -> Result<Vec<String>>
}
}
pub fn save_playlist<T>(name: &str, owner: &str, content: &Vec<String>, db: &T) -> Result<()>
pub fn save_playlist<T>(playlist_name: &str, owner: &str, content: &Vec<String>, db: &T) -> Result<()>
where T: ConnectionSource + VFSSource
{
let user: User;
@ -96,7 +96,7 @@ pub fn save_playlist<T>(name: &str, owner: &str, content: &Vec<String>, db: &T)
// Create playlist
new_playlist = NewPlaylist {
name: name.into(),
name: playlist_name.into(),
owner: user.id,
};
@ -107,7 +107,7 @@ pub fn save_playlist<T>(name: &str, owner: &str, content: &Vec<String>, db: &T)
{
use self::playlists::dsl::*;
playlist = playlists
.filter(name.eq(name).and(owner.eq(user.id)))
.filter(name.eq(playlist_name).and(owner.eq(user.id)))
.get_result(connection.deref())?;
}
}