From d32334088e17058f9e85496eadbf251c11ab3a5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Sun, 4 Apr 2021 23:24:52 +0200 Subject: [PATCH] [backend] list_roots() returns Addresses directly, fix bug with resolving parentless directories --- src/filesystem.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/filesystem.rs b/src/filesystem.rs index 7536f62..e863d43 100644 --- a/src/filesystem.rs +++ b/src/filesystem.rs @@ -209,7 +209,7 @@ impl EntryList for Vec { } } -pub fn list_roots>(connection: &C) -> Result> { +pub fn list_roots>(connection: &C) -> Result> { let all_directories: Vec = query( connection, Query::SingleQuery(QueryPart::Matches(EntryQuery { @@ -232,6 +232,7 @@ pub fn list_roots>(connection: &C) -> Result>( path: &UPath, ) -> Result> { 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
= resolve_path(connection, path, false)?; let last = resolved_path.last().unwrap(); @@ -306,7 +304,13 @@ pub fn fetch_or_create_dir>( .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() {