Skip to content

Commit ba4cc82

Browse files
committed
Add runCatching for cache initialization
1 parent 84ba38c commit ba4cc82

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

  • tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/ui/screen/webimport/common/di

tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/ui/screen/webimport/common/di/NetworkModule.kt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package io.github.composegears.valkyrie.ui.screen.webimport.common.di
22

33
import com.composegears.leviathan.Leviathan
44
import com.intellij.openapi.application.PathManager
5+
import com.intellij.openapi.diagnostic.Logger
56
import io.ktor.client.HttpClient
67
import io.ktor.client.engine.okhttp.OkHttp
78
import io.ktor.client.plugins.HttpTimeout
@@ -32,9 +33,17 @@ object NetworkModule : Leviathan() {
3233
json(inject(json))
3334
}
3435
install(HttpCache) {
35-
val cacheDir = Paths.get(PathManager.getSystemPath()).resolve("valkyrie")
36-
val cacheFile = Files.createDirectories(cacheDir).toFile()
37-
publicStorage(FileStorage(cacheFile))
36+
runCatching {
37+
val cacheDir = Paths.get(PathManager.getSystemPath())
38+
.resolve("valkyrie")
39+
.resolve("http-cache")
40+
val cacheFile = Files.createDirectories(cacheDir).toFile()
41+
42+
publicStorage(FileStorage(cacheFile))
43+
}.onFailure {
44+
Logger.getInstance(NetworkModule::class.java)
45+
.error("Failed to create http cache dir: ${it.message}")
46+
}
3847
}
3948
}
4049
}

0 commit comments

Comments
 (0)