mirror of
https://github.com/YGGverse/btracker.git
synced 2026-03-31 09:05:30 +00:00
make sure the keyword is really empty (does not contain separators only)
This commit is contained in:
parent
e2e7ceda9d
commit
50bdb438b5
1 changed files with 39 additions and 38 deletions
|
|
@ -103,6 +103,10 @@ impl Public {
|
||||||
keyword: Option<&str>,
|
keyword: Option<&str>,
|
||||||
sort_order: Option<(Sort, Order)>,
|
sort_order: Option<(Sort, Order)>,
|
||||||
) -> Result<Vec<File>, Error> {
|
) -> Result<Vec<File>, Error> {
|
||||||
|
const S: &[char] = &[
|
||||||
|
'_', '-', ':', ';', ',', '(', ')', '[', ']', '/', '!', '?',
|
||||||
|
' ', // @TODO make separators list optional
|
||||||
|
];
|
||||||
let mut files = Vec::with_capacity(self.default_capacity);
|
let mut files = Vec::with_capacity(self.default_capacity);
|
||||||
for dir_entry in fs::read_dir(&self.root)? {
|
for dir_entry in fs::read_dir(&self.root)? {
|
||||||
let entry = dir_entry?;
|
let entry = dir_entry?;
|
||||||
|
|
@ -111,13 +115,10 @@ impl Public {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if let Some(k) = keyword
|
if let Some(k) = keyword
|
||||||
&& !k.is_empty()
|
&& !k.trim_matches(S).is_empty()
|
||||||
&& !librqbit_core::torrent_metainfo::torrent_from_bytes(&fs::read(&path)?)
|
&& !librqbit_core::torrent_metainfo::torrent_from_bytes(&fs::read(&path)?)
|
||||||
.is_ok_and(|m: librqbit_core::torrent_metainfo::TorrentMetaV1Owned| {
|
.is_ok_and(|m: librqbit_core::torrent_metainfo::TorrentMetaV1Owned| {
|
||||||
k.split([
|
k.split(S)
|
||||||
'_', '-', ':', ';', ',', '(', ')', '[', ']', '/', '!', '?',
|
|
||||||
' ', // @TODO make separators list optional
|
|
||||||
])
|
|
||||||
.filter(|s| !s.is_empty())
|
.filter(|s| !s.is_empty())
|
||||||
.map(|s| s.trim().to_lowercase())
|
.map(|s| s.trim().to_lowercase())
|
||||||
.all(|q| {
|
.all(|q| {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue