Skip to content

Commit

Permalink
rectify
Browse files Browse the repository at this point in the history
Signed-off-by: Thang PHAM <[email protected]>
  • Loading branch information
thangqp committed Dec 2, 2024
1 parent a1ed72f commit e5a7f0b
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,16 @@ public Consumer<Message<String>> consumeCancel() {
return super.consumeCancel();
}

@Override
protected void clean(AbstractResultContext<DynamicSimulationRunContext> resultContext) {
super.clean(resultContext);
if (!resultContext.getRunContext().isDebug()) {
// clean dump directory
Path dumpDir = getDumpDir(resultContext.getRunContext().getDynamicSimulationParameters());
removeDirectory(dumpDir);
}
}

// --- Dump file related methods --- //

private void setupDumpParameters(Path workDir, DynamicSimulationParameters parameters) {
Expand Down Expand Up @@ -242,4 +252,16 @@ private byte[] zipDumpFile(Path dumpDir) {
}
return outputState;
}

private void removeDirectory(Path dir) {
if (dir != null) {
try {
FileUtil.removeDir(dir);
} catch (IOException e) {
LOGGER.error(String.format("%s: Error occurred while cleaning directory at %s", getComputationType(), dir.toAbsolutePath()), e);
}
} else {
LOGGER.info("{}: No directory to clean", getComputationType());
}
}
}

0 comments on commit e5a7f0b

Please sign in to comment.