1
0
Fork 1
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:
carbotaniuman 2020-06-28 12:36:30 -05:00
parent edf416cfa6
commit 0e6af9e7d3

View file

@ -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)