forked from j62/ctbrec
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();
|
onlineMonitor.shutdown();
|
||||||
recorder.shutdown(immediately);
|
recorder.shutdown(immediately);
|
||||||
|
scheduler.shutdownNow();
|
||||||
for (Site site : sites) {
|
for (Site site : sites) {
|
||||||
if (site.isEnabled()) {
|
if (site.isEnabled()) {
|
||||||
site.shutdown();
|
site.shutdown();
|
||||||
|
@ -412,6 +413,7 @@ public class CamrecApplication extends Application {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Config.getInstance().save();
|
Config.getInstance().save();
|
||||||
|
clearHttpCache();
|
||||||
LOG.info("Shutdown complete. Goodbye!");
|
LOG.info("Shutdown complete. Goodbye!");
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
primaryStage.close();
|
primaryStage.close();
|
||||||
|
@ -431,17 +433,22 @@ public class CamrecApplication extends Application {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
ExternalBrowser.getInstance().close();
|
ExternalBrowser.getInstance().close();
|
||||||
HttpClientCacheProvider.getCache(config).evictAll();
|
|
||||||
HttpClientCacheProvider.getCache(config).close();
|
|
||||||
IoUtils.deleteDirectory(new File(config.getConfigDir(), "cache"));
|
|
||||||
} catch (IOException e12) {
|
} catch (IOException e12) {
|
||||||
// noop
|
// noop
|
||||||
}
|
}
|
||||||
scheduler.shutdownNow();
|
|
||||||
}).start();
|
}).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() {
|
private void registerAlertSystem() {
|
||||||
for (EventHandlerConfiguration eventHandlerConfig : Config.getInstance().getSettings().eventHandlers) {
|
for (EventHandlerConfiguration eventHandlerConfig : Config.getInstance().getSettings().eventHandlers) {
|
||||||
var handler = new EventHandler(eventHandlerConfig);
|
var handler = new EventHandler(eventHandlerConfig);
|
||||||
|
|
Loading…
Reference in New Issue