diff --git a/core/src/main/groovy/com/muwire/core/MuWireSettings.groovy b/core/src/main/groovy/com/muwire/core/MuWireSettings.groovy index 5ff0e51c..b4546a48 100644 --- a/core/src/main/groovy/com/muwire/core/MuWireSettings.groovy +++ b/core/src/main/groovy/com/muwire/core/MuWireSettings.groovy @@ -20,6 +20,7 @@ class MuWireSettings { Set watchedDirectories float downloadSequentialRatio int hostClearInterval + int meshExpiration MuWireSettings() { this(new Properties()) @@ -37,6 +38,7 @@ class MuWireSettings { shareDownloadedFiles = Boolean.parseBoolean(props.getProperty("shareDownloadedFiles","true")) downloadSequentialRatio = Float.valueOf(props.getProperty("downloadSequentialRatio","0.8")) hostClearInterval = Integer.valueOf(props.getProperty("hostClearInterval","60")) + meshExpiration = Integer.valueOf(props.getProperty("meshExpiration","60")) watchedDirectories = new HashSet<>() if (props.containsKey("watchedDirectories")) { @@ -58,6 +60,7 @@ class MuWireSettings { props.setProperty("shareDownloadedFiles", String.valueOf(shareDownloadedFiles)) props.setProperty("downloadSequentialRatio", String.valueOf(downloadSequentialRatio)) props.setProperty("hostClearInterval", String.valueOf(hostClearInterval)) + props.setProperty("meshExpiration", String.valueOf(meshExpiration)) if (!watchedDirectories.isEmpty()) { String encoded = watchedDirectories.stream(). diff --git a/core/src/main/groovy/com/muwire/core/mesh/MeshManager.groovy b/core/src/main/groovy/com/muwire/core/mesh/MeshManager.groovy index 034a0905..474b0357 100644 --- a/core/src/main/groovy/com/muwire/core/mesh/MeshManager.groovy +++ b/core/src/main/groovy/com/muwire/core/mesh/MeshManager.groovy @@ -17,8 +17,6 @@ import net.i2p.data.Base64 class MeshManager { - private static final int EXPIRATION = 60 * 60 * 1000 - private final Map meshes = Collections.synchronizedMap(new HashMap<>()) private final FileManager fileManager private final File home @@ -83,7 +81,7 @@ class MeshManager { JsonSlurper slurper = new JsonSlurper() meshFile.eachLine { def json = slurper.parseText(it) - if (now - json.timestamp > EXPIRATION) + if (now - json.timestamp > settings.meshExpiration * 60 * 1000) return InfoHash infoHash = new InfoHash(Base64.decode(json.infoHash)) Pieces pieces = new Pieces(json.nPieces, settings.downloadSequentialRatio)