Compare commits
5 Commits
muwire-0.3
...
fix-piece-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e829e09b13 | ||
|
|
120980100b | ||
|
|
e64ed2c89d | ||
|
|
81436aaa66 | ||
|
|
3bb530e34f |
@@ -35,7 +35,7 @@ class Cli {
|
||||
|
||||
Core core
|
||||
try {
|
||||
core = new Core(props, home, "0.3.9")
|
||||
core = new Core(props, home, "0.3.8")
|
||||
} catch (Exception bad) {
|
||||
bad.printStackTrace(System.out)
|
||||
println "Failed to initialize core, exiting"
|
||||
|
||||
@@ -53,7 +53,7 @@ class CliDownloader {
|
||||
|
||||
Core core
|
||||
try {
|
||||
core = new Core(props, home, "0.3.9")
|
||||
core = new Core(props, home, "0.3.8")
|
||||
} catch (Exception bad) {
|
||||
bad.printStackTrace(System.out)
|
||||
println "Failed to initialize core, exiting"
|
||||
|
||||
@@ -297,7 +297,7 @@ public class Core {
|
||||
}
|
||||
}
|
||||
|
||||
Core core = new Core(props, home, "0.3.9")
|
||||
Core core = new Core(props, home, "0.3.8")
|
||||
core.startServices()
|
||||
|
||||
// ... at the end, sleep or execute script
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.muwire.core.mesh
|
||||
|
||||
import java.util.logging.Level
|
||||
import java.util.stream.Collectors
|
||||
|
||||
import com.muwire.core.Constants
|
||||
@@ -12,8 +13,10 @@ import com.muwire.core.util.DataUtil
|
||||
|
||||
import groovy.json.JsonOutput
|
||||
import groovy.json.JsonSlurper
|
||||
import groovy.util.logging.Log
|
||||
import net.i2p.data.Base64
|
||||
|
||||
@Log
|
||||
class MeshManager {
|
||||
|
||||
private static final int EXPIRATION = 60 * 60 * 1000
|
||||
@@ -36,6 +39,7 @@ class MeshManager {
|
||||
synchronized(meshes) {
|
||||
if (meshes.containsKey(infoHash))
|
||||
return meshes.get(infoHash)
|
||||
log.log(Level.INFO,"creating mesh with pieces:$nPieces", new Exception())
|
||||
Pieces pieces = new Pieces(nPieces, Constants.DOWNLOAD_SEQUENTIAL_RATIO)
|
||||
if (fileManager.rootToFiles.containsKey(infoHash)) {
|
||||
for (int i = 0; i < nPieces; i++)
|
||||
|
||||
@@ -12,8 +12,10 @@ import com.muwire.core.connection.Endpoint
|
||||
import com.muwire.core.mesh.Mesh
|
||||
import com.muwire.core.util.DataUtil
|
||||
|
||||
import groovy.util.logging.Log
|
||||
import net.i2p.data.Destination
|
||||
|
||||
@Log
|
||||
class ContentUploader extends Uploader {
|
||||
|
||||
private final File file
|
||||
@@ -42,8 +44,10 @@ class ContentUploader extends Uploader {
|
||||
int endPiece = range.end / (0x1 << pieceSize)
|
||||
for (int i = startPiece; i <= endPiece; i++)
|
||||
satisfiable &= mesh.pieces.isDownloaded(i)
|
||||
log.info("requested range $range.start-$range.end startPiece:$startPiece endPiece:$endPiece satisfiable:$satisfiable my pieces: ${mesh.pieces.getDownloaded()}")
|
||||
}
|
||||
if (!satisfiable) {
|
||||
log.info("416 range not satisfiable")
|
||||
os.write("416 Range Not Satisfiable\r\n".getBytes(StandardCharsets.US_ASCII))
|
||||
writeMesh(request.downloader)
|
||||
os.write("\r\n".getBytes(StandardCharsets.US_ASCII))
|
||||
@@ -51,6 +55,8 @@ class ContentUploader extends Uploader {
|
||||
return
|
||||
}
|
||||
|
||||
log.info("200 ok")
|
||||
|
||||
os.write("200 OK\r\n".getBytes(StandardCharsets.US_ASCII))
|
||||
os.write("Content-Range: $range.start-$range.end\r\n".getBytes(StandardCharsets.US_ASCII))
|
||||
writeMesh(request.downloader)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
group = com.muwire
|
||||
version = 0.3.9
|
||||
version = 0.3.8
|
||||
groovyVersion = 2.4.15
|
||||
slf4jVersion = 1.7.25
|
||||
spockVersion = 1.1-groovy-2.4
|
||||
|
||||
Reference in New Issue
Block a user