Fix deletion of HTTP cache on shutdown
This commit is contained in:
parent
ef66aebeda
commit
de282d24a6
|
@ -405,6 +405,7 @@ public class CamrecApplication extends Application {
|
|||
}
|
||||
onlineMonitor.shutdown();
|
||||
recorder.shutdown(immediately);
|
||||
scheduler.shutdownNow();
|
||||
for (Site site : sites) {
|
||||
if (site.isEnabled()) {
|
||||
site.shutdown();
|
||||
|
@ -412,6 +413,7 @@ public class CamrecApplication extends Application {
|
|||
}
|
||||
try {
|
||||
Config.getInstance().save();
|
||||
clearHttpCache();
|
||||
LOG.info("Shutdown complete. Goodbye!");
|
||||
Platform.runLater(() -> {
|
||||
primaryStage.close();
|
||||
|
@ -431,17 +433,22 @@ public class CamrecApplication extends Application {
|
|||
}
|
||||
try {
|
||||
ExternalBrowser.getInstance().close();
|
||||
HttpClientCacheProvider.getCache(config).evictAll();
|
||||
HttpClientCacheProvider.getCache(config).close();
|
||||
IoUtils.deleteDirectory(new File(config.getConfigDir(), "cache"));
|
||||
} catch (IOException e12) {
|
||||
// noop
|
||||
}
|
||||
scheduler.shutdownNow();
|
||||
}).start();
|
||||
|
||||
}
|
||||
|
||||
private void clearHttpCache() throws IOException {
|
||||
File httpCacheDir = new File(config.getConfigDir(), "cache");
|
||||
LOG.debug("Deleting http cache {}", httpCacheDir);
|
||||
HttpClientCacheProvider.getCache(config).evictAll();
|
||||
HttpClientCacheProvider.getCache(config).close();
|
||||
IoUtils.deleteDirectory(httpCacheDir);
|
||||
LOG.debug("Cache has been deleted");
|
||||
}
|
||||
|
||||
private void registerAlertSystem() {
|
||||
for (EventHandlerConfiguration eventHandlerConfig : Config.getInstance().getSettings().eventHandlers) {
|
||||
var handler = new EventHandler(eventHandlerConfig);
|
||||
|
|
Loading…
Reference in New Issue