mirror of
https://github.com/agersant/polaris
synced 2025-03-02 06:17:10 +00:00
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::*;
|
||||
let vfs = db.get_vfs()?;
|
||||
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> = songs
|
||||
.filter(path.like(&like_path))
|
||||
.order(path)
|
||||
.load(connection.deref())?;
|
||||
|
||||
let real_songs: Vec<Song> = if virtual_path.parent() != None {
|
||||
let real_path = vfs.virtual_to_real(virtual_path)?;
|
||||
let like_path = real_path.as_path().to_string_lossy().into_owned() + "%";
|
||||
songs
|
||||
.filter(path.like(&like_path))
|
||||
.order(path)
|
||||
.load(connection.deref())?
|
||||
} else {
|
||||
songs.order(path).load(connection.deref())?
|
||||
};
|
||||
|
||||
let virtual_songs = real_songs
|
||||
.into_iter()
|
||||
.filter_map(|s| virtualize_song(&vfs, s));
|
||||
|
|
Loading…
Add table
Reference in a new issue