Skip to content

Commit b6fba07

Browse files
committed
chore: use global data dir from the settings
removes duplicate logic which was already existing in the settings store.
1 parent d0f4357 commit b6fba07

File tree

1 file changed

+3
-29
lines changed

1 file changed

+3
-29
lines changed

src/main/kotlin/com/coder/toolbox/feed/IdeFeedManager.kt

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@ import com.coder.toolbox.CoderToolboxContext
44
import com.coder.toolbox.plugin.PluginManager
55
import com.coder.toolbox.sdk.CoderHttpClientBuilder
66
import com.coder.toolbox.sdk.interceptors.Interceptors
7-
import com.coder.toolbox.util.OS
87
import com.coder.toolbox.util.ReloadableTlsContext
9-
import com.coder.toolbox.util.getOS
108
import com.squareup.moshi.Moshi
119
import com.squareup.moshi.Types
1210
import kotlinx.coroutines.Dispatchers
1311
import kotlinx.coroutines.withContext
1412
import retrofit2.Retrofit
1513
import retrofit2.converter.moshi.MoshiConverterFactory
1614
import java.nio.file.Path
15+
import java.nio.file.Paths
1716
import kotlin.io.path.exists
1817
import kotlin.io.path.readText
1918

@@ -131,43 +130,18 @@ class IdeFeedManager(
131130
return allIdes
132131
}
133132

134-
/**
135-
* Get the platform-specific cache directory path.
136-
*/
137-
private fun getCacheDirectory(): Path {
138-
val os = getOS()
139-
val userHome = System.getProperty("user.home")
140-
141-
val basePath = when (os) {
142-
OS.MAC -> Path.of(userHome, "Library", "Application Support")
143-
OS.LINUX -> Path.of(userHome, ".local", "share")
144-
OS.WINDOWS -> {
145-
val localAppData = System.getenv("LOCALAPPDATA")
146-
?: Path.of(userHome, "AppData", "Local").toString()
147-
Path.of(localAppData)
148-
}
149-
150-
null -> {
151-
context.logger.warn("Unable to determine OS, using home directory for cache")
152-
Path.of(userHome, ".cache")
153-
}
154-
}
155-
156-
return basePath.resolve("JetBrains/Toolbox/plugins/com.coder.toolbox")
157-
}
158-
159133
/**
160134
* Get the path for the release feed cache file.
161135
*/
162136
private fun getReleaseCachePath(): Path {
163-
return getCacheDirectory().resolve(RELEASE_CACHE_FILE)
137+
return Paths.get(context.settingsStore.globalDataDirectory, RELEASE_CACHE_FILE)
164138
}
165139

166140
/**
167141
* Get the path for the EAP feed cache file.
168142
*/
169143
private fun getEapCachePath(): Path {
170-
return getCacheDirectory().resolve(EAP_CACHE_FILE)
144+
return Paths.get(context.settingsStore.globalDataDirectory, EAP_CACHE_FILE)
171145
}
172146

173147
/**

0 commit comments

Comments
 (0)