mirror of
https://gitee.com/BDWare/agent-backend
synced 2025-01-10 01:44:14 +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);
|
private static final Logger LOGGER = LogManager.getLogger(DOIPOverHttpHandler.class);
|
||||||
Map<String, ZipFile> zipFilePool = new HashMap<>();
|
Map<String, ZipFile> zipFilePool = new HashMap<>();
|
||||||
Map<String, Long> lastVisit = new HashMap<>();
|
Map<String, Long> lastVisit = new HashMap<>();
|
||||||
|
Map<String, Long> lastModified = new HashMap<>();
|
||||||
|
|
||||||
public synchronized void pruneZipPool() {
|
public synchronized void pruneZipPool() {
|
||||||
Set<String> toPrune = new HashSet<>();
|
Set<String> toPrune = new HashSet<>();
|
||||||
@ -45,6 +46,7 @@ public class DOIPOverHttpHandler {
|
|||||||
ZipFile zf = zipFilePool.get(str);
|
ZipFile zf = zipFilePool.get(str);
|
||||||
zipFilePool.remove(str);
|
zipFilePool.remove(str);
|
||||||
lastVisit.remove(str);
|
lastVisit.remove(str);
|
||||||
|
lastModified.remove(str);
|
||||||
zf.close();
|
zf.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
@ -162,7 +164,6 @@ public class DOIPOverHttpHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sendAssets(JsonObject arg, ChannelHandlerContext ctx) throws Exception {
|
private void sendAssets(JsonObject arg, ChannelHandlerContext ctx) throws Exception {
|
||||||
|
|
||||||
ContractMeta meta =
|
ContractMeta meta =
|
||||||
CMActions.manager.statusRecorder.getContractMeta(
|
CMActions.manager.statusRecorder.getContractMeta(
|
||||||
arg.get("contractID").getAsString());
|
arg.get("contractID").getAsString());
|
||||||
@ -199,10 +200,22 @@ public class DOIPOverHttpHandler {
|
|||||||
try {
|
try {
|
||||||
ZipFile cachedFile = zipFilePool.get(scriptStr);
|
ZipFile cachedFile = zipFilePool.get(scriptStr);
|
||||||
if (cachedFile == null) {
|
if (cachedFile == null) {
|
||||||
|
File f = new File(scriptStr);
|
||||||
cachedFile =
|
cachedFile =
|
||||||
new ZipFile(new File(scriptStr));
|
new ZipFile(f);
|
||||||
zipFilePool.put(scriptStr, cachedFile);
|
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());
|
lastVisit.put(scriptStr, System.currentTimeMillis());
|
||||||
return cachedFile;
|
return cachedFile;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -681,7 +681,11 @@ public class NodeCenterClientController implements NodeCenterConn {
|
|||||||
|
|
||||||
@Action(async = true)
|
@Action(async = true)
|
||||||
public void onDistributeYPK(JsonObject json, ResultCallback rc) {
|
public void onDistributeYPK(JsonObject json, ResultCallback rc) {
|
||||||
onDistribute(json, rc);
|
try {
|
||||||
|
onDistribute(json, rc);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Action(async = true)
|
@Action(async = true)
|
||||||
|
Loading…
Reference in New Issue
Block a user