diff --git a/core/src/main/groovy/com/muwire/core/upload/ContentRequest.groovy b/core/src/main/groovy/com/muwire/core/upload/ContentRequest.groovy index fa500f13..36db6b3b 100644 --- a/core/src/main/groovy/com/muwire/core/upload/ContentRequest.groovy +++ b/core/src/main/groovy/com/muwire/core/upload/ContentRequest.groovy @@ -2,5 +2,5 @@ package com.muwire.core.upload class ContentRequest extends Request { Range range - boolean have + int have } diff --git a/core/src/main/groovy/com/muwire/core/upload/ContentUploader.groovy b/core/src/main/groovy/com/muwire/core/upload/ContentUploader.groovy index 7928c730..cacc7f02 100644 --- a/core/src/main/groovy/com/muwire/core/upload/ContentUploader.groovy +++ b/core/src/main/groovy/com/muwire/core/upload/ContentUploader.groovy @@ -105,4 +105,14 @@ class ContentUploader extends Uploader { request.downloader.getHumanReadableName() } + @Override + public int getDonePieces() { + return request.have; + } + + @Override + public int getTotalPieces() { + return mesh.pieces.nPieces; + } + } diff --git a/core/src/main/groovy/com/muwire/core/upload/HashListUploader.groovy b/core/src/main/groovy/com/muwire/core/upload/HashListUploader.groovy index 9085f0aa..64ccf652 100644 --- a/core/src/main/groovy/com/muwire/core/upload/HashListUploader.groovy +++ b/core/src/main/groovy/com/muwire/core/upload/HashListUploader.groovy @@ -50,6 +50,16 @@ class HashListUploader extends Uploader { public String getDownloader() { request.downloader.getHumanReadableName() } + + @Override + public int getDonePieces() { + return 0; + } + + @Override + public int getTotalPieces() { + return 1; + } } diff --git a/core/src/main/groovy/com/muwire/core/upload/Request.groovy b/core/src/main/groovy/com/muwire/core/upload/Request.groovy index a27acd59..864ecf47 100644 --- a/core/src/main/groovy/com/muwire/core/upload/Request.groovy +++ b/core/src/main/groovy/com/muwire/core/upload/Request.groovy @@ -50,10 +50,10 @@ class Request { downloader = new Persona(new ByteArrayInputStream(decoded)) } - boolean have = false + int have = 0 if (headers.containsKey("X-Have")) { def encoded = headers["X-Have"].trim() - have = DataUtil.decodeXHave(encoded).size() > 0 + have = DataUtil.decodeXHave(encoded).size() } new ContentRequest( infoHash : infoHash, range : new Range(start, end), headers : headers, downloader : downloader, have : have) diff --git a/core/src/main/groovy/com/muwire/core/upload/UploadManager.groovy b/core/src/main/groovy/com/muwire/core/upload/UploadManager.groovy index 83f90d57..c268f490 100644 --- a/core/src/main/groovy/com/muwire/core/upload/UploadManager.groovy +++ b/core/src/main/groovy/com/muwire/core/upload/UploadManager.groovy @@ -80,7 +80,7 @@ public class UploadManager { return } - if (request.have) + if (request.have > 0) eventBus.publish(new SourceDiscoveredEvent(infoHash : request.infoHash, source : request.downloader)) Mesh mesh @@ -205,7 +205,7 @@ public class UploadManager { return } - if (request.have) + if (request.have > 0) eventBus.publish(new SourceDiscoveredEvent(infoHash : request.infoHash, source : request.downloader)) Mesh mesh diff --git a/core/src/main/groovy/com/muwire/core/upload/Uploader.groovy b/core/src/main/groovy/com/muwire/core/upload/Uploader.groovy index c0bbfbd6..ce0489b1 100644 --- a/core/src/main/groovy/com/muwire/core/upload/Uploader.groovy +++ b/core/src/main/groovy/com/muwire/core/upload/Uploader.groovy @@ -32,4 +32,8 @@ abstract class Uploader { abstract int getProgress(); abstract String getDownloader(); + + abstract int getDonePieces(); + + abstract int getTotalPieces() } diff --git a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy index c67e0029..9f8afa60 100644 --- a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy @@ -185,11 +185,14 @@ class MainFrameView { closureColumn(header : "Name", type : String, read : {row -> row.getName() }) closureColumn(header : "Progress", type : String, read : { row -> int percent = row.getProgress() - "$percent% of piece" + "$percent% of piece".toString() }) closureColumn(header : "Downloader", type : String, read : { row -> row.getDownloader() }) + closureColumn(header : "Remote Pieces", type : String, read : { row -> + "${row.getDonePieces()}/${row.getTotalPieces()}".toString() + }) } } }