diff --git a/core/src/main/groovy/com/muwire/core/download/DownloadManager.groovy b/core/src/main/groovy/com/muwire/core/download/DownloadManager.groovy index cbf7721d..72d6943e 100644 --- a/core/src/main/groovy/com/muwire/core/download/DownloadManager.groovy +++ b/core/src/main/groovy/com/muwire/core/download/DownloadManager.groovy @@ -135,6 +135,9 @@ public class DownloadManager { else incompletes = new File(home, "incompletes") + if (json.pieceSizePow2 == null || json.pieceSizePow2 == 0) + return // skip this download as it's corrupt anyway + Pieces pieces = getPieces(infoHash, (long)json.length, json.pieceSizePow2, sequential) def downloader = new Downloader(eventBus, this, me, file, (long)json.length, 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 9f0eb5e5..3189eb1e 100644 --- a/core/src/main/groovy/com/muwire/core/search/ResultsParser.groovy +++ b/core/src/main/groovy/com/muwire/core/search/ResultsParser.groovy @@ -30,11 +30,11 @@ class ResultsParser { private static parseV1(Persona p, UUID uuid, def json) { if (json.name == null) throw new InvalidSearchResultException("name missing") - if (json.size == null) + if (json.size == null || json.size == 0) throw new InvalidSearchResultException("length missing") if (json.infohash == null) throw new InvalidSearchResultException("infohash missing") - if (json.pieceSize == null) + if (json.pieceSize == null || json.pieceSize == 0) throw new InvalidSearchResultException("pieceSize missing") if (!(json.hashList instanceof List)) throw new InvalidSearchResultException("hashlist not a list") @@ -71,11 +71,11 @@ class ResultsParser { private static UIResultEvent parseV2(Persona p, UUID uuid, def json) { if (json.name == null) throw new InvalidSearchResultException("name missing") - if (json.size == null) + if (json.size == null || json.size == 0) throw new InvalidSearchResultException("length missing") if (json.infohash == null) throw new InvalidSearchResultException("infohash missing") - if (json.pieceSize == null) + if (json.pieceSize == null || json.pieceSize) throw new InvalidSearchResultException("pieceSize missing") if (json.hashList != null) throw new InvalidSearchResultException("V2 result with hashlist")