Compare commits

..

1 Commits

Author SHA1 Message Date
Zlatin Balevsky
7718dc0821 force UTF8 for json serialization 2019-06-16 12:13:00 +01:00
10 changed files with 13 additions and 57 deletions

View File

@@ -34,7 +34,7 @@ class Cli {
Core core
try {
core = new Core(props, home, "0.2.2")
core = new Core(props, home, "0.2.1")
} catch (Exception bad) {
bad.printStackTrace(System.out)
println "Failed to initialize core, exiting"

View File

@@ -53,7 +53,7 @@ class CliDownloader {
Core core
try {
core = new Core(props, home, "0.2.2")
core = new Core(props, home, "0.2.1")
} catch (Exception bad) {
bad.printStackTrace(System.out)
println "Failed to initialize core, exiting"

View File

@@ -268,7 +268,7 @@ public class Core {
}
}
Core core = new Core(props, home, "0.2.2")
Core core = new Core(props, home, "0.2.1")
core.startServices()
// ... at the end, sleep or execute script

View File

@@ -2,6 +2,7 @@ package com.muwire.core.connection
import java.io.InputStream
import java.io.OutputStream
import java.nio.charset.StandardCharsets
import com.muwire.core.EventBus
import com.muwire.core.MuWireSettings
@@ -66,7 +67,7 @@ class PeerConnection extends Connection {
protected void write(Object message) {
byte[] payload
if (message instanceof Map) {
payload = JsonOutput.toJson(message).bytes
payload = JsonOutput.toJson(message).getBytes(StandardCharsets.UTF_8)
DataUtil.packHeader(payload.length, writeHeader)
log.fine "$name writing message type ${message.type} length $payload.length"
writeHeader[0] &= (byte)0x7F

View File

@@ -51,23 +51,4 @@ class ContentUploader extends Uploader {
}
}
@Override
public String getName() {
return file.getName();
}
@Override
public synchronized int getProgress() {
if (mapped == null)
return 0
int position = mapped.position()
int total = request.getRange().end - request.getRange().start
(int)(position * 100.0 / total)
}
@Override
public String getDownloader() {
request.downloader.getHumanReadableName()
}
}

View File

@@ -6,8 +6,6 @@ import java.nio.charset.StandardCharsets
import com.muwire.core.InfoHash
import com.muwire.core.connection.Endpoint
import net.i2p.data.Base64
class HashListUploader extends Uploader {
private final InfoHash infoHash
private final HashListRequest request
@@ -16,7 +14,6 @@ class HashListUploader extends Uploader {
super(endpoint)
this.infoHash = infoHash
mapped = ByteBuffer.wrap(infoHash.getHashList())
this.request = request
}
void respond() {
@@ -35,21 +32,4 @@ class HashListUploader extends Uploader {
}
endpoint.getOutputStream().flush()
}
@Override
public String getName() {
return "Hash list for " + Base64.encode(infoHash.getRoot());
}
@Override
public synchronized int getProgress() {
(int)(mapped.position() * 100.0 / mapped.capacity())
}
@Override
public String getDownloader() {
request.downloader.getHumanReadableName()
}
}

View File

@@ -23,13 +23,4 @@ abstract class Uploader {
return -1
mapped.position()
}
abstract String getName();
/**
* @return an integer between 0 and 100
*/
abstract int getProgress();
abstract String getDownloader();
}

View File

@@ -1,5 +1,5 @@
group = com.muwire
version = 0.2.2
version = 0.2.1
groovyVersion = 2.4.15
slf4jVersion = 1.7.25
spockVersion = 1.1-groovy-2.4

View File

@@ -62,7 +62,7 @@ class MainFrameController {
def searchEvent
if (hashSearch) {
searchEvent = new SearchEvent(searchHash : root, uuid : uuid, oobInfohash: true)
searchEvent = new SearchEvent(searchHash : root, uuid : uuid)
} else {
// this can be improved a lot
def replaced = search.toLowerCase().trim().replaceAll(Constants.SPLIT_PATTERN, " ")

View File

@@ -160,13 +160,16 @@ class MainFrameView {
scrollPane (constraints : BorderLayout.CENTER) {
table(id : "uploads-table") {
tableModel(list : model.uploads) {
closureColumn(header : "Name", type : String, read : {row -> row.getName() })
closureColumn(header : "Name", type : String, read : {row -> row.file.getName() })
closureColumn(header : "Progress", type : String, read : { row ->
int percent = row.getProgress()
int position = row.getPosition()
def range = row.request.getRange()
int total = range.end - range.start
int percent = (int)((position * 100.0) / total)
"$percent%"
})
closureColumn(header : "Downloader", type : String, read : { row ->
row.getDownloader()
row.request.downloader?.getHumanReadableName()
})
}
}