Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ src/main/resources/META-INF/services/com.itangcent.common.spi.SetupAble
/envs
out/

plugin-adapter/build/
plugin-adapter/plugin-adapter-markdown/build/
gradle/wrapper/caches
gradle/wrapper/daemon
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.itangcent.common.logger.Log
import com.itangcent.common.utils.*
import com.itangcent.idea.icons.EasyIcons
import com.itangcent.idea.icons.iconOnly
import com.itangcent.idea.plugin.api.cache.ProjectCacheRepository
import com.itangcent.idea.plugin.api.export.postman.PostmanCachedApiHelper
import com.itangcent.idea.plugin.api.export.postman.PostmanUrls.INTEGRATIONS_DASHBOARD
import com.itangcent.idea.plugin.api.export.postman.PostmanWorkspace
Expand All @@ -27,6 +28,8 @@ import com.itangcent.idea.utils.Charsets
import com.itangcent.idea.utils.SwingUtils
import com.itangcent.idea.utils.isDoubleClick
import com.itangcent.intellij.context.ActionContext
import com.itangcent.intellij.file.DefaultLocalFileRepository
import com.itangcent.intellij.file.LocalFileRepository
import com.itangcent.intellij.logger.Logger
import java.awt.event.MouseAdapter
import java.awt.event.MouseEvent
Expand Down Expand Up @@ -448,37 +451,37 @@ class EasyApiSettingGUI : AbstractEasyApiSettingGUI() {
}

private fun computeProjectCacheSize() {
val currentProject = myProject ?: return
val projectBasePath = currentProject.basePath
val cachePath = "$projectBasePath${File.separator}.idea${File.separator}.cache${File.separator}$basePath"
val cachePath = actionContext.instance(ProjectCacheRepository::class).cachePath()
val cacheSize = computeFolderSize(cachePath)
actionContext.runInSwingUI {
this.projectCacheSizeLabel!!.text = StringUtil.formatFileSize(cacheSize)
}
}

private fun clearProjectCache() {
val currentProject = myProject ?: return
val projectBasePath = currentProject.basePath
val cachePath = "$projectBasePath${File.separator}.idea${File.separator}.cache${File.separator}$basePath"
val cachePath = actionContext.instance(ProjectCacheRepository::class).cachePath()
deleteFolder(cachePath)
computeProjectCacheSize()
}

private fun computeGlobalCacheSize() {
val cachePath = "${globalBasePath()}${File.separator}$basePath"
val cachePath = actionContext.instance(DefaultLocalFileRepository::class).cachePath()
val cacheSize = computeFolderSize(cachePath)
actionContext.runInSwingUI {
this.globalCacheSizeLabel!!.text = StringUtil.formatFileSize(cacheSize)
}
}

private fun clearGlobalCache() {
val cachePath = "${globalBasePath()}${File.separator}$basePath"
val cachePath = actionContext.instance(DefaultLocalFileRepository::class).cachePath()
deleteFolder(cachePath)
computeGlobalCacheSize()
}

private fun LocalFileRepository.cachePath(): String {
return this.getOrCreateFile(".setting.size").parentFile.path
}

private fun computeFolderSize(path: String): Long {
val file = File(path)
if (file.exists()) {
Expand All @@ -505,15 +508,6 @@ class EasyApiSettingGUI : AbstractEasyApiSettingGUI() {
settings.setPostmanCollectionsPairs(pairs)
}

private fun globalBasePath(): String {

var home = SystemUtils.userHome
if (home.endsWith(File.separator)) {
home = home.substring(0, home.length - 1)
}
return home
}

private class PostmanWorkspaceData {

var id: String?
Expand Down Expand Up @@ -630,8 +624,6 @@ class EasyApiSettingGUI : AbstractEasyApiSettingGUI() {
}

companion object : Log() {
const val basePath = ".easy_api"

const val setting_path = "easy.api.setting.path"

private var DEFAULT_WORKSPACE = PostmanWorkspaceData(null, "")
Expand Down
Loading