diff --git a/src/main/java/org/bdware/server/http/DOIPOverHttpHandler.java b/src/main/java/org/bdware/server/http/DOIPOverHttpHandler.java index d1ffa4e..d3396cc 100644 --- a/src/main/java/org/bdware/server/http/DOIPOverHttpHandler.java +++ b/src/main/java/org/bdware/server/http/DOIPOverHttpHandler.java @@ -30,6 +30,7 @@ public class DOIPOverHttpHandler { private static final Logger LOGGER = LogManager.getLogger(DOIPOverHttpHandler.class); Map zipFilePool = new HashMap<>(); Map lastVisit = new HashMap<>(); + Map lastModified = new HashMap<>(); public synchronized void pruneZipPool() { Set toPrune = new HashSet<>(); @@ -45,6 +46,7 @@ public class DOIPOverHttpHandler { ZipFile zf = zipFilePool.get(str); zipFilePool.remove(str); lastVisit.remove(str); + lastModified.remove(str); zf.close(); } catch (Exception e) { @@ -162,7 +164,6 @@ public class DOIPOverHttpHandler { } private void sendAssets(JsonObject arg, ChannelHandlerContext ctx) throws Exception { - ContractMeta meta = CMActions.manager.statusRecorder.getContractMeta( arg.get("contractID").getAsString()); @@ -199,10 +200,22 @@ public class DOIPOverHttpHandler { try { ZipFile cachedFile = zipFilePool.get(scriptStr); if (cachedFile == null) { + File f = new File(scriptStr); cachedFile = - new ZipFile(new File(scriptStr)); + new ZipFile(f); zipFilePool.put(scriptStr, cachedFile); + lastModified.put(scriptStr, f.lastModified()); + } else { + File f = new File(scriptStr); + if (lastModified.get(scriptStr) != f.lastModified()) { + cachedFile.close(); + cachedFile = + new ZipFile(f); + zipFilePool.put(scriptStr, cachedFile); + lastModified.put(scriptStr, f.lastModified()); + } } + lastVisit.put(scriptStr, System.currentTimeMillis()); return cachedFile; } catch (Exception e) { diff --git a/src/main/java/org/bdware/server/nodecenter/client/NodeCenterClientController.java b/src/main/java/org/bdware/server/nodecenter/client/NodeCenterClientController.java index 897ef57..3c64a38 100644 --- a/src/main/java/org/bdware/server/nodecenter/client/NodeCenterClientController.java +++ b/src/main/java/org/bdware/server/nodecenter/client/NodeCenterClientController.java @@ -681,7 +681,11 @@ public class NodeCenterClientController implements NodeCenterConn { @Action(async = true) public void onDistributeYPK(JsonObject json, ResultCallback rc) { - onDistribute(json, rc); + try { + onDistribute(json, rc); + } catch (IOException e) { + e.printStackTrace(); + } } @Action(async = true)