refactor(komga-tray): add more logs around open explorer action

This commit is contained in:
Gauthier Roebroeck 2023-10-18 16:24:55 +08:00
parent a47eddbbac
commit db06919898
2 changed files with 8 additions and 1 deletions

View file

@ -1,9 +1,12 @@
package org.gotson.komga package org.gotson.komga
import mu.KotlinLogging
import java.awt.Desktop import java.awt.Desktop
import java.io.File import java.io.File
import java.net.URI import java.net.URI
private val logger = KotlinLogging.logger {}
fun openUrl(url: String) { fun openUrl(url: String) {
if (Desktop.isDesktopSupported()) if (Desktop.isDesktopSupported())
Desktop.getDesktop().let { Desktop.getDesktop().let {
@ -12,8 +15,12 @@ fun openUrl(url: String) {
} }
fun openExplorer(file: File) { fun openExplorer(file: File) {
logger.info { "Try to open explorer for path: $file" }
if (Desktop.isDesktopSupported()) if (Desktop.isDesktopSupported())
Desktop.getDesktop().let { Desktop.getDesktop().let {
if (it.isSupported(Desktop.Action.BROWSE_FILE_DIR)) it.browseFileDirectory(file) if (it.isSupported(Desktop.Action.BROWSE_FILE_DIR)) it.browseFileDirectory(file)
else logger.warn { "Cannot open explorer: Desktop.Action.BROWSE_FILE_DIR is not supported" }
} }
else
logger.warn { "Cannot open explorer: Desktop is not supported" }
} }

View file

@ -63,7 +63,7 @@ dependencies {
implementation("org.flywaydb:flyway-core") implementation("org.flywaydb:flyway-core")
implementation("io.github.microutils:kotlin-logging-jvm:3.0.5") api("io.github.microutils:kotlin-logging-jvm:3.0.5")
implementation("io.hawt:hawtio-springboot:2.17.6") implementation("io.hawt:hawtio-springboot:2.17.6")
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0") implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0")