Merge branch 'emptysearchcrash' into 'next'
fix: crash on empty search Closes #190 See merge request famedly/conduit!286
This commit is contained in:
commit
dffa5570e7
4 changed files with 22 additions and 20 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -2018,7 +2018,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "reqwest"
|
name = "reqwest"
|
||||||
version = "0.11.9"
|
version = "0.11.9"
|
||||||
source = "git+https://github.com/niuhuan/reqwest?branch=dns-resolver-fn#57b7cf4feb921573dfafad7d34b9ac6e44ead0bd"
|
source = "git+https://github.com/timokoesters/reqwest?rev=57b7cf4feb921573dfafad7d34b9ac6e44ead0bd#57b7cf4feb921573dfafad7d34b9ac6e44ead0bd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.13.0",
|
"base64 0.13.0",
|
||||||
"bytes",
|
"bytes",
|
||||||
|
|
|
@ -48,7 +48,7 @@ rand = "0.8.4"
|
||||||
# Used to hash passwords
|
# Used to hash passwords
|
||||||
rust-argon2 = "0.8.3"
|
rust-argon2 = "0.8.3"
|
||||||
# Used to send requests
|
# Used to send requests
|
||||||
reqwest = { version = "0.11.4", default-features = false, features = ["rustls-tls", "socks"], git = "https://github.com/niuhuan/reqwest", branch = "dns-resolver-fn" }
|
reqwest = { default-features = false, features = ["rustls-tls", "socks"], git = "https://github.com/timokoesters/reqwest", rev = "57b7cf4feb921573dfafad7d34b9ac6e44ead0bd" }
|
||||||
# Used for conduit::Error type
|
# Used for conduit::Error type
|
||||||
thiserror = "1.0.28"
|
thiserror = "1.0.28"
|
||||||
# Used to generate thumbnails for images
|
# Used to generate thumbnails for images
|
||||||
|
|
|
@ -44,11 +44,12 @@ pub async fn search_events_route(
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let search = db
|
if let Some(search) = db
|
||||||
.rooms
|
.rooms
|
||||||
.search_pdus(&room_id, &search_criteria.search_term)?;
|
.search_pdus(&room_id, &search_criteria.search_term)?
|
||||||
|
{
|
||||||
searches.push(search.0.peekable());
|
searches.push(search.0.peekable());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let skip = match body.next_batch.as_ref().map(|s| s.parse()) {
|
let skip = match body.next_batch.as_ref().map(|s| s.parse()) {
|
||||||
|
|
|
@ -2771,7 +2771,7 @@ impl Rooms {
|
||||||
&'a self,
|
&'a self,
|
||||||
room_id: &RoomId,
|
room_id: &RoomId,
|
||||||
search_string: &str,
|
search_string: &str,
|
||||||
) -> Result<(impl Iterator<Item = Vec<u8>> + 'a, Vec<String>)> {
|
) -> Result<Option<(impl Iterator<Item = Vec<u8>> + 'a, Vec<String>)>> {
|
||||||
let prefix = self
|
let prefix = self
|
||||||
.get_shortroomid(room_id)?
|
.get_shortroomid(room_id)?
|
||||||
.expect("room exists")
|
.expect("room exists")
|
||||||
|
@ -2799,19 +2799,20 @@ impl Rooms {
|
||||||
.map(|(key, _)| key[key.len() - size_of::<u64>()..].to_vec())
|
.map(|(key, _)| key[key.len() - size_of::<u64>()..].to_vec())
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok((
|
Ok(utils::common_elements(iterators, |a, b| {
|
||||||
utils::common_elements(iterators, |a, b| {
|
// We compare b with a because we reversed the iterator earlier
|
||||||
// We compare b with a because we reversed the iterator earlier
|
b.cmp(a)
|
||||||
b.cmp(a)
|
})
|
||||||
})
|
.map(|iter| {
|
||||||
.unwrap()
|
(
|
||||||
.map(move |id| {
|
iter.map(move |id| {
|
||||||
let mut pduid = prefix_clone.clone();
|
let mut pduid = prefix_clone.clone();
|
||||||
pduid.extend_from_slice(&id);
|
pduid.extend_from_slice(&id);
|
||||||
pduid
|
pduid
|
||||||
}),
|
}),
|
||||||
words,
|
words,
|
||||||
))
|
)
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
|
|
Loading…
Reference in a new issue