mirror of
https://gitlab.com/mangadex-pub/mangadex_at_home.git
synced 2024-01-19 02:48:37 +00:00
Add sanity guard
This commit is contained in:
parent
edf416cfa6
commit
0e6af9e7d3
|
@ -101,14 +101,16 @@ class MangaDexClient(private val clientSettings: ClientSettings) {
|
||||||
|
|
||||||
executorService.scheduleAtFixedRate({
|
executorService.scheduleAtFixedRate({
|
||||||
try {
|
try {
|
||||||
statistics.updateAndGet {
|
if (state is Running || state is GracefulShutdown || state is Uninitialized) {
|
||||||
it.copy(bytesOnDisk = cache.size())
|
statistics.updateAndGet {
|
||||||
}
|
it.copy(bytesOnDisk = cache.size())
|
||||||
statsMap[Instant.now()] = statistics.get()
|
}
|
||||||
val editor = cache.edit("statistics")
|
statsMap[Instant.now()] = statistics.get()
|
||||||
if (editor != null) {
|
val editor = cache.edit("statistics")
|
||||||
JACKSON.writeValue(editor.newOutputStream(0), statistics.get())
|
if (editor != null) {
|
||||||
editor.commit()
|
JACKSON.writeValue(editor.newOutputStream(0), statistics.get())
|
||||||
|
editor.commit()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
LOGGER.warn("Statistics update failed", e)
|
LOGGER.warn("Statistics update failed", e)
|
||||||
|
|
Loading…
Reference in a new issue