From 4e28e6020bb408906969e2f107df6d07e31308cb Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Tue, 5 Oct 2021 00:51:35 +0100 Subject: [PATCH] do not transmit path information if there is none --- .../groovy/com/muwire/core/search/ResultsParser.groovy | 2 +- .../groovy/com/muwire/core/search/ResultsSender.groovy | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) 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 0e4b405b..b3cddabd 100644 --- a/core/src/main/groovy/com/muwire/core/search/ResultsParser.groovy +++ b/core/src/main/groovy/com/muwire/core/search/ResultsParser.groovy @@ -136,7 +136,7 @@ class ResultsParser { uuid: uuid, certificates : certificates, collections : collections, - path: path.toArray(new String[0])) + path: path.isEmpty() ? null : path.toArray(new String[0])) } catch (Exception e) { throw new InvalidSearchResultException("parsing search result failed",e) } diff --git a/core/src/main/groovy/com/muwire/core/search/ResultsSender.groovy b/core/src/main/groovy/com/muwire/core/search/ResultsSender.groovy index e41c0033..b7b6c232 100644 --- a/core/src/main/groovy/com/muwire/core/search/ResultsSender.groovy +++ b/core/src/main/groovy/com/muwire/core/search/ResultsSender.groovy @@ -210,10 +210,14 @@ class ResultsSender { if (showPaths) { List path = new ArrayList<>() if (sf.getPathToSharedParent() != null) { - for (Path element : sf.getPathToSharedParent()) - path << Base64.encode(DataUtil.encodei18nString(element.toString())) + for (Path element : sf.getPathToSharedParent()) { + String toString = element.toString() + if (!toString.isEmpty()) + path << Base64.encode(DataUtil.encodei18nString(toString)) + } } - obj.path = path + if (!path.isEmpty()) + obj.path = path } obj