From d2231b8e3877b7c3aa5bba364e7ea23bd1d4d3a7 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Sat, 1 Jun 2019 07:20:39 +0100 Subject: [PATCH] attach uuid to search results --- .../com/muwire/core/connection/ConnectionAcceptor.groovy | 2 +- .../main/groovy/com/muwire/core/search/ResultsParser.groovy | 5 +++-- .../main/groovy/com/muwire/core/search/UIResultEvent.groovy | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/src/main/groovy/com/muwire/core/connection/ConnectionAcceptor.groovy b/core/src/main/groovy/com/muwire/core/connection/ConnectionAcceptor.groovy index 9e4c69d3..0454a49f 100644 --- a/core/src/main/groovy/com/muwire/core/connection/ConnectionAcceptor.groovy +++ b/core/src/main/groovy/com/muwire/core/connection/ConnectionAcceptor.groovy @@ -204,7 +204,7 @@ class ConnectionAcceptor { byte [] payload = new byte[jsonSize] dis.readFully(payload) def json = slurper.parse(payload) - eventBus.publish(ResultsParser.parse(sender, json)) + eventBus.publish(ResultsParser.parse(sender, resultsUUID, json)) } } catch (IOException | UnexpectedResultsException | InvalidSearchResultException bad) { log.log(Level.WARNING, "failed to process POST", bad) diff --git a/core/src/main/groovy/com/muwire/core/search/ResultsParser.groovy b/core/src/main/groovy/com/muwire/core/search/ResultsParser.groovy index 6024bf63..38e0cef4 100644 --- a/core/src/main/groovy/com/muwire/core/search/ResultsParser.groovy +++ b/core/src/main/groovy/com/muwire/core/search/ResultsParser.groovy @@ -9,7 +9,7 @@ import com.muwire.core.util.DataUtil import net.i2p.data.Base64 class ResultsParser { - public static UIResultEvent parse(Persona p, def json) throws InvalidSearchResultException { + public static UIResultEvent parse(Persona p, UUID uuid, def json) throws InvalidSearchResultException { if (json.type != "Result") throw new InvalidSearchResultException("not a result json") if (json.version != 1) @@ -46,7 +46,8 @@ class ResultsParser { name : name, size : size, infohash : parsedIH, - pieceSize : pieceSize) + pieceSize : pieceSize, + uuid : uuid) } catch (Exception e) { throw new InvalidSearchResultException("parsing search result failed",e) } diff --git a/core/src/main/groovy/com/muwire/core/search/UIResultEvent.groovy b/core/src/main/groovy/com/muwire/core/search/UIResultEvent.groovy index 1ed1e1dd..9aa86ab3 100644 --- a/core/src/main/groovy/com/muwire/core/search/UIResultEvent.groovy +++ b/core/src/main/groovy/com/muwire/core/search/UIResultEvent.groovy @@ -6,6 +6,7 @@ import com.muwire.core.Persona class UIResultEvent extends Event { Persona sender + UUID uuid String name long size InfoHash infohash