diff options
| author | JP Dillingham <jp@dillingham.me> | 2024-02-25 14:36:21 -0600 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2024-02-25 14:36:21 -0600 |
| commit | 92e5bd61becad8877d2733696260556db6c8a514 (patch) | |
| tree | ef6bcff67eab6727b9c9ccc9469eda76e13560b8 /src | |
| parent | 4cf7752282adb80a9e6d20187d50745e77e67bf0 (diff) | |
| download | slskd-92e5bd61becad8877d2733696260556db6c8a514.tar.gz | |
filter using substring matching on filenames
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Shares/SqliteShareRepository.cs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/slskd/Shares/SqliteShareRepository.cs b/src/slskd/Shares/SqliteShareRepository.cs index 882ede74..029d74b8 100644 --- a/src/slskd/Shares/SqliteShareRepository.cs +++ b/src/slskd/Shares/SqliteShareRepository.cs @@ -539,6 +539,17 @@ namespace slskd.Shares while (reader.Read()) { var filename = reader.GetString(0); + + // SQLite takes care of matching on tokens, but unfortunately doesn't work in cases where an exclusion appears as a substring. + // example: the token matching works to exclude the result "foo bar baz" given a "bar" exclusion, but does not exclude "foo xbarx baz" + // for this reason we must iterate over the exclusion list and ensure none appear as substrings + // **CAUTION** performance of this will degrade exponentially as the list of exclusions grows + if (query.Exclusions.Any(x => filename.Contains(x, StringComparison.OrdinalIgnoreCase))) + { + Log.Debug("Dropping excluded filename {File}", filename); + continue; + } + var code = reader.GetInt32(1); var size = reader.GetInt64(2); var extension = reader.GetString(3); |
