Fix FileNode/query to return all results when no query is provided
This commit is contained in:
@@ -61,6 +61,28 @@ impl DavResources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn shared_documents(
|
||||||
|
&self,
|
||||||
|
access_token: &AccessToken,
|
||||||
|
check_acls: impl IntoIterator<Item = Acl>,
|
||||||
|
match_any: bool,
|
||||||
|
) -> RoaringBitmap {
|
||||||
|
let shared_containers = self.shared_containers(access_token, check_acls, match_any);
|
||||||
|
let mut document_ids = shared_containers.clone();
|
||||||
|
|
||||||
|
if !shared_containers.is_empty() {
|
||||||
|
for path in &self.paths {
|
||||||
|
if let Some(parent_id) = path.parent_id
|
||||||
|
&& shared_containers.contains(parent_id)
|
||||||
|
{
|
||||||
|
document_ids.insert(self.resources[path.resource_idx].document_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
document_ids
|
||||||
|
}
|
||||||
|
|
||||||
pub fn has_access_to_container(
|
pub fn has_access_to_container(
|
||||||
&self,
|
&self,
|
||||||
access_token: &AccessToken,
|
access_token: &AccessToken,
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ impl FileNodeGet for Server {
|
|||||||
.map(|r| r.document_id)
|
.map(|r| r.document_id)
|
||||||
.collect::<RoaringBitmap>()
|
.collect::<RoaringBitmap>()
|
||||||
} else {
|
} else {
|
||||||
cache.shared_containers(access_token, [Acl::Read, Acl::ReadItems], true)
|
cache.shared_documents(access_token, [Acl::Read, Acl::ReadItems], true)
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut ids = if let Some(ids) = ids {
|
let mut ids = if let Some(ids) = ids {
|
||||||
|
|||||||
@@ -96,15 +96,15 @@ impl FileNodeQuery for Server {
|
|||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
let set = match want_container {
|
let set = match want_container {
|
||||||
Some(is_container) => RoaringBitmap::from_iter(
|
Some(is_container) => {
|
||||||
cache.resources.iter().filter_map(|r| {
|
RoaringBitmap::from_iter(cache.resources.iter().filter_map(|r| {
|
||||||
if r.is_container() == is_container {
|
if r.is_container() == is_container {
|
||||||
Some(r.document_id)
|
Some(r.document_id)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}),
|
}))
|
||||||
),
|
}
|
||||||
// TODO: support symlink nodeType once target storage exists
|
// TODO: support symlink nodeType once target storage exists
|
||||||
None => RoaringBitmap::new(),
|
None => RoaringBitmap::new(),
|
||||||
};
|
};
|
||||||
@@ -194,9 +194,9 @@ impl FileNodeQuery for Server {
|
|||||||
let results = SearchQuery::new(SearchIndex::InMemory)
|
let results = SearchQuery::new(SearchIndex::InMemory)
|
||||||
.with_filters(filters)
|
.with_filters(filters)
|
||||||
.with_mask(if access_token.is_shared(account_id) {
|
.with_mask(if access_token.is_shared(account_id) {
|
||||||
cache.shared_containers(access_token, [Acl::ReadItems], true)
|
cache.shared_documents(access_token, [Acl::Read, Acl::ReadItems], true)
|
||||||
} else {
|
} else {
|
||||||
cache.document_ids(false).collect()
|
cache.resources.iter().map(|r| r.document_id).collect()
|
||||||
})
|
})
|
||||||
.filter()
|
.filter()
|
||||||
.into_bitmap();
|
.into_bitmap();
|
||||||
@@ -246,9 +246,9 @@ impl FileNodeQuery for Server {
|
|||||||
FileNodeComparator::Name => ra
|
FileNodeComparator::Name => ra
|
||||||
.and_then(|r| r.container_name())
|
.and_then(|r| r.container_name())
|
||||||
.cmp(&rb.and_then(|r| r.container_name())),
|
.cmp(&rb.and_then(|r| r.container_name())),
|
||||||
FileNodeComparator::Size => ra
|
FileNodeComparator::Size => {
|
||||||
.and_then(|r| r.size())
|
ra.and_then(|r| r.size()).cmp(&rb.and_then(|r| r.size()))
|
||||||
.cmp(&rb.and_then(|r| r.size())),
|
}
|
||||||
FileNodeComparator::NodeType => {
|
FileNodeComparator::NodeType => {
|
||||||
// Directories sort before files
|
// Directories sort before files
|
||||||
let a_dir = ra.map(|r| r.is_container()).unwrap_or(false);
|
let a_dir = ra.map(|r| r.is_container()).unwrap_or(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user