@@ -11,6 +11,7 @@ import com.itangcent.common.logger.Log
1111import com.itangcent.common.utils.*
1212import com.itangcent.idea.icons.EasyIcons
1313import com.itangcent.idea.icons.iconOnly
14+ import com.itangcent.idea.plugin.api.cache.ProjectCacheRepository
1415import com.itangcent.idea.plugin.api.export.postman.PostmanCachedApiHelper
1516import com.itangcent.idea.plugin.api.export.postman.PostmanUrls.INTEGRATIONS_DASHBOARD
1617import com.itangcent.idea.plugin.api.export.postman.PostmanWorkspace
@@ -27,6 +28,8 @@ import com.itangcent.idea.utils.Charsets
2728import com.itangcent.idea.utils.SwingUtils
2829import com.itangcent.idea.utils.isDoubleClick
2930import com.itangcent.intellij.context.ActionContext
31+ import com.itangcent.intellij.file.DefaultLocalFileRepository
32+ import com.itangcent.intellij.file.LocalFileRepository
3033import com.itangcent.intellij.logger.Logger
3134import java.awt.event.MouseAdapter
3235import java.awt.event.MouseEvent
@@ -448,37 +451,37 @@ class EasyApiSettingGUI : AbstractEasyApiSettingGUI() {
448451 }
449452
450453 private fun computeProjectCacheSize () {
451- val currentProject = myProject ? : return
452- val projectBasePath = currentProject.basePath
453- val cachePath = " $projectBasePath${File .separator} .idea${File .separator} .cache${File .separator}$basePath "
454+ val cachePath = actionContext.instance(ProjectCacheRepository ::class ).cachePath()
454455 val cacheSize = computeFolderSize(cachePath)
455456 actionContext.runInSwingUI {
456457 this .projectCacheSizeLabel!! .text = StringUtil .formatFileSize(cacheSize)
457458 }
458459 }
459460
460461 private fun clearProjectCache () {
461- val currentProject = myProject ? : return
462- val projectBasePath = currentProject.basePath
463- val cachePath = " $projectBasePath${File .separator} .idea${File .separator} .cache${File .separator}$basePath "
462+ val cachePath = actionContext.instance(ProjectCacheRepository ::class ).cachePath()
464463 deleteFolder(cachePath)
465464 computeProjectCacheSize()
466465 }
467466
468467 private fun computeGlobalCacheSize () {
469- val cachePath = " ${globalBasePath()}${ File .separator}$basePath "
468+ val cachePath = actionContext.instance( DefaultLocalFileRepository :: class ).cachePath()
470469 val cacheSize = computeFolderSize(cachePath)
471470 actionContext.runInSwingUI {
472471 this .globalCacheSizeLabel!! .text = StringUtil .formatFileSize(cacheSize)
473472 }
474473 }
475474
476475 private fun clearGlobalCache () {
477- val cachePath = " ${globalBasePath()}${ File .separator}$basePath "
476+ val cachePath = actionContext.instance( DefaultLocalFileRepository :: class ).cachePath()
478477 deleteFolder(cachePath)
479478 computeGlobalCacheSize()
480479 }
481480
481+ private fun LocalFileRepository.cachePath (): String {
482+ return this .getOrCreateFile(" .setting.size" ).parentFile.path
483+ }
484+
482485 private fun computeFolderSize (path : String ): Long {
483486 val file = File (path)
484487 if (file.exists()) {
@@ -505,15 +508,6 @@ class EasyApiSettingGUI : AbstractEasyApiSettingGUI() {
505508 settings.setPostmanCollectionsPairs(pairs)
506509 }
507510
508- private fun globalBasePath (): String {
509-
510- var home = SystemUtils .userHome
511- if (home.endsWith(File .separator)) {
512- home = home.substring(0 , home.length - 1 )
513- }
514- return home
515- }
516-
517511 private class PostmanWorkspaceData {
518512
519513 var id: String?
@@ -630,8 +624,6 @@ class EasyApiSettingGUI : AbstractEasyApiSettingGUI() {
630624 }
631625
632626 companion object : Log () {
633- const val basePath = " .easy_api"
634-
635627 const val setting_path = " easy.api.setting.path"
636628
637629 private var DEFAULT_WORKSPACE = PostmanWorkspaceData (null , " " )
0 commit comments