[backend] list_roots() returns Addresses directly, fix bug with resolving parentless directories
parent
4804cea634
commit
d32334088e
|
@ -209,7 +209,7 @@ impl EntryList for Vec<Entry> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn list_roots<C: Connection<Backend = Sqlite>>(connection: &C) -> Result<Vec<Entry>> {
|
||||
pub fn list_roots<C: Connection<Backend = Sqlite>>(connection: &C) -> Result<Vec<Address>> {
|
||||
let all_directories: Vec<Entry> = query(
|
||||
connection,
|
||||
Query::SingleQuery(QueryPart::Matches(EntryQuery {
|
||||
|
@ -232,6 +232,7 @@ pub fn list_roots<C: Connection<Backend = Sqlite>>(connection: &C) -> Result<Vec
|
|||
Ok(all_directories
|
||||
.into_iter()
|
||||
.filter(|entry| !directories_with_parents.contains(&entry.entity))
|
||||
.map(|e| e.entity)
|
||||
.collect())
|
||||
}
|
||||
|
||||
|
@ -240,10 +241,7 @@ pub async fn list_directory<C: Connection<Backend = Sqlite>>(
|
|||
path: &UPath,
|
||||
) -> Result<Vec<Entry>> {
|
||||
let entry_addresses = match path.0.len() {
|
||||
0 => list_roots(connection)?
|
||||
.into_iter()
|
||||
.map(|e| e.entity)
|
||||
.collect(),
|
||||
0 => list_roots(connection)?,
|
||||
_ => {
|
||||
let resolved_path: Vec<Address> = resolve_path(connection, path, false)?;
|
||||
let last = resolved_path.last().unwrap();
|
||||
|
@ -306,7 +304,13 @@ pub fn fetch_or_create_dir<C: Connection<Backend = Sqlite>>(
|
|||
.filter(|a| parent_has.contains(a))
|
||||
.collect()
|
||||
}
|
||||
None => matching_directories,
|
||||
None => {
|
||||
let roots = list_roots(connection)?;
|
||||
matching_directories
|
||||
.into_iter()
|
||||
.filter(|a| roots.contains(a))
|
||||
.collect()
|
||||
}
|
||||
};
|
||||
|
||||
match valid_directories.len() {
|
||||
|
|
Loading…
Reference in New Issue