Fixed a bug where it was not possible to flatten the entire collection
This commit is contained in:
parent
e9010fd39d
commit
54c5704133
1 changed files with 12 additions and 6 deletions
18
src/index.rs
18
src/index.rs
|
@ -524,12 +524,18 @@ pub fn flatten<T>(db: &T, virtual_path: &Path) -> Result<Vec<Song>>
|
||||||
use self::songs::dsl::*;
|
use self::songs::dsl::*;
|
||||||
let vfs = db.get_vfs()?;
|
let vfs = db.get_vfs()?;
|
||||||
let connection = db.get_connection();
|
let connection = db.get_connection();
|
||||||
let real_path = vfs.virtual_to_real(virtual_path)?;
|
|
||||||
let like_path = real_path.as_path().to_string_lossy().into_owned() + "%";
|
let real_songs: Vec<Song> = if virtual_path.parent() != None {
|
||||||
let real_songs: Vec<Song> = songs
|
let real_path = vfs.virtual_to_real(virtual_path)?;
|
||||||
.filter(path.like(&like_path))
|
let like_path = real_path.as_path().to_string_lossy().into_owned() + "%";
|
||||||
.order(path)
|
songs
|
||||||
.load(connection.deref())?;
|
.filter(path.like(&like_path))
|
||||||
|
.order(path)
|
||||||
|
.load(connection.deref())?
|
||||||
|
} else {
|
||||||
|
songs.order(path).load(connection.deref())?
|
||||||
|
};
|
||||||
|
|
||||||
let virtual_songs = real_songs
|
let virtual_songs = real_songs
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|s| virtualize_song(&vfs, s));
|
.filter_map(|s| virtualize_song(&vfs, s));
|
||||||
|
|
Loading…
Add table
Reference in a new issue