Fixed a bug where content wasn't ordered reliably

This commit is contained in:
Antoine Gersant 2016-10-30 22:16:29 -07:00
parent 0d6d7f442d
commit f7a01f7e0b

View file

@ -442,7 +442,7 @@ impl Index {
let mut output = Vec::new(); let mut output = Vec::new();
let path_string = real_path.to_string_lossy(); let path_string = real_path.to_string_lossy();
let mut select = db.prepare("SELECT path, artwork, year, artist, album FROM directories WHERE parent = ?").unwrap(); let mut select = db.prepare("SELECT path, artwork, year, artist, album FROM directories WHERE parent = ? ORDER BY path ASC").unwrap();
select.bind(1, &Value::String(path_string.deref().to_owned())).unwrap(); select.bind(1, &Value::String(path_string.deref().to_owned())).unwrap();
while let State::Row = select.next().unwrap() { while let State::Row = select.next().unwrap() {
@ -480,7 +480,7 @@ impl Index {
fn browse_songs(&self, real_path: &Path) -> Vec<CollectionFile> { fn browse_songs(&self, real_path: &Path) -> Vec<CollectionFile> {
let db = self.connect(); let db = self.connect();
let path_string = real_path.to_string_lossy(); let path_string = real_path.to_string_lossy();
let mut select = db.prepare("SELECT path, track_number, title, year, album_artist, artist, album, artwork FROM songs WHERE parent = ?").unwrap(); let mut select = db.prepare("SELECT path, track_number, title, year, album_artist, artist, album, artwork FROM songs WHERE parent = ? ORDER BY path ASC").unwrap();
select.bind(1, &Value::String(path_string.deref().to_owned())).unwrap(); select.bind(1, &Value::String(path_string.deref().to_owned())).unwrap();
self.select_songs(&mut select).into_iter().map(|s| CollectionFile::Song(s)).collect() self.select_songs(&mut select).into_iter().map(|s| CollectionFile::Song(s)).collect()
} }
@ -518,7 +518,7 @@ impl Index {
let db = self.connect(); let db = self.connect();
let real_path = try!(self.vfs.virtual_to_real(virtual_path)); let real_path = try!(self.vfs.virtual_to_real(virtual_path));
let path_string = real_path.to_string_lossy().into_owned() + "%"; let path_string = real_path.to_string_lossy().into_owned() + "%";
let mut select = db.prepare("SELECT path, track_number, title, year, album_artist, artist, album, artwork FROM songs WHERE path LIKE ?").unwrap(); let mut select = db.prepare("SELECT path, track_number, title, year, album_artist, artist, album, artwork FROM songs WHERE path LIKE ? ORDER BY path").unwrap();
select.bind(1, &Value::String(path_string.deref().to_owned())).unwrap(); select.bind(1, &Value::String(path_string.deref().to_owned())).unwrap();
Ok(self.select_songs(&mut select)) Ok(self.select_songs(&mut select))
} }