mirror of
https://gitee.com/BDWare/agent-backend
synced 2025-01-09 17:34:13 +00:00
fix: assets file cache bugs
This commit is contained in:
parent
926078e081
commit
e93c07ed84
@ -30,6 +30,7 @@ public class DOIPOverHttpHandler {
|
||||
private static final Logger LOGGER = LogManager.getLogger(DOIPOverHttpHandler.class);
|
||||
Map<String, ZipFile> zipFilePool = new HashMap<>();
|
||||
Map<String, Long> lastVisit = new HashMap<>();
|
||||
Map<String, Long> lastModified = new HashMap<>();
|
||||
|
||||
public synchronized void pruneZipPool() {
|
||||
Set<String> 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) {
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user