Fix minor pathological cases
This commit is contained in:
parent
535d21ec8e
commit
af73354d4f
|
@ -45,16 +45,17 @@ import java.util.concurrent.atomic.AtomicBoolean
|
|||
class ClientSettingsException(message: String) : Exception(message)
|
||||
|
||||
class MangaDexClient(private val settingsFile: File, databaseFile: File, cacheFolder: File) {
|
||||
// just for scheduling one task, so single-threaded
|
||||
// this must remain single-threaded because of how the state mechanism works
|
||||
private val executor = Executors.newSingleThreadScheduledExecutor()
|
||||
private val isReloading = AtomicBoolean(false)
|
||||
|
||||
private val database: Database
|
||||
private val cache: DiskLruCache
|
||||
private var settings: ClientSettings
|
||||
|
||||
// state that must only be accessed from the thread on the executor
|
||||
private var imageServer: ServerManager? = null
|
||||
private var webUi: Http4kServer? = null
|
||||
// end protected state
|
||||
|
||||
init {
|
||||
settings = try {
|
||||
|
@ -145,6 +146,7 @@ class MangaDexClient(private val settingsFile: File, databaseFile: File, cacheFo
|
|||
}
|
||||
|
||||
fun shutdown() {
|
||||
executor.schedule({
|
||||
LOGGER.info { "Mangadex@Home Client shutting down" }
|
||||
if (webUi != null) {
|
||||
stopWebUi()
|
||||
|
@ -159,6 +161,7 @@ class MangaDexClient(private val settingsFile: File, databaseFile: File, cacheFo
|
|||
} catch (e: IOException) {
|
||||
LOGGER.error(e) { "Cache failed to close" }
|
||||
}
|
||||
}, 0, TimeUnit.SECONDS)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,7 +37,7 @@ class ServerManager(serverSettings: ServerSettings, devSettings: DevSettings, ma
|
|||
// this must remain single-threaded because of how the state mechanism works
|
||||
private val executor = Executors.newSingleThreadScheduledExecutor()
|
||||
|
||||
// state that must only be accessed from the thread on the executorService
|
||||
// state that must only be accessed from the thread on the executor
|
||||
private var state: State
|
||||
private var serverHandler: ServerHandler
|
||||
// end protected state
|
||||
|
|
Loading…
Reference in a new issue