From bd3555dce90a38798bba0694c4e5de2610086009 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Mon, 10 Jan 2022 11:29:35 +0000 Subject: [PATCH] propagate regex flag in queries in preparation for regex search --- .../main/groovy/com/muwire/core/connection/Connection.groovy | 5 +++++ .../main/groovy/com/muwire/core/search/SearchEvent.groovy | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/src/main/groovy/com/muwire/core/connection/Connection.groovy b/core/src/main/groovy/com/muwire/core/connection/Connection.groovy index 12d7bf37..ee5e3d8b 100644 --- a/core/src/main/groovy/com/muwire/core/connection/Connection.groovy +++ b/core/src/main/groovy/com/muwire/core/connection/Connection.groovy @@ -157,6 +157,7 @@ abstract class Connection implements Closeable { query.compressedResults = e.searchEvent.compressedResults query.collections = e.searchEvent.collections query.searchPaths = e.searchEvent.searchPaths + query.regex = e.searchEvent.regex if (e.searchEvent.searchHash != null) query.infohash = Base64.encode(e.searchEvent.searchHash) query.replyTo = e.replyTo.toBase64() @@ -286,6 +287,9 @@ abstract class Connection implements Closeable { boolean searchPaths = false if (search.searchPaths != null) searchPaths = search.searchPaths + boolean regex = false + if (search.regex != null) + regex = search.regex byte[] sig = null if (search.sig != null) { @@ -342,6 +346,7 @@ abstract class Connection implements Closeable { compressedResults : compressedResults, collections : collections, searchPaths: searchPaths, + regex: regex, persona : originator) QueryEvent event = new QueryEvent ( searchEvent : searchEvent, replyTo : replyTo, diff --git a/core/src/main/groovy/com/muwire/core/search/SearchEvent.groovy b/core/src/main/groovy/com/muwire/core/search/SearchEvent.groovy index 58f6be4e..d53388a6 100644 --- a/core/src/main/groovy/com/muwire/core/search/SearchEvent.groovy +++ b/core/src/main/groovy/com/muwire/core/search/SearchEvent.groovy @@ -15,11 +15,14 @@ class SearchEvent extends Event { Persona persona boolean collections boolean searchPaths + boolean regex String toString() { def infoHash = null if (searchHash != null) infoHash = new InfoHash(searchHash) - "searchTerms: $searchTerms searchHash:$infoHash, uuid:$uuid oobInfohash:$oobInfohash searchComments:$searchComments compressedResults:$compressedResults" + "searchTerms: $searchTerms searchHash:$infoHash, uuid:$uuid " + + "oobInfohash:$oobInfohash searchComments:$searchComments " + + "compressedResults:$compressedResults regex:$regex" } }