diff --git a/platform/configuration-store-impl/src/StreamProvider.kt b/platform/configuration-store-impl/src/StreamProvider.kt
index 160b4ac34d1a..e09dd685c704 100644
--- a/platform/configuration-store-impl/src/StreamProvider.kt
+++ b/platform/configuration-store-impl/src/StreamProvider.kt
@@ -22,16 +22,16 @@ public interface StreamProvider {
public open val enabled: Boolean
get() = true
- public open fun isApplicable(fileSpec: String, roamingType: RoamingType): Boolean = true
+ public open fun isApplicable(fileSpec: String, roamingType: RoamingType = RoamingType.PER_USER): Boolean = true
/**
* @param fileSpec
* @param content bytes of content, size of array is not actual size of data, you must use `size`
* @param size actual size of data
*/
- public fun write(fileSpec: String, content: ByteArray, size: Int, roamingType: RoamingType)
+ public fun write(fileSpec: String, content: ByteArray, size: Int = content.size(), roamingType: RoamingType = RoamingType.PER_USER)
- public fun read(fileSpec: String, roamingType: RoamingType): InputStream?
+ public fun read(fileSpec: String, roamingType: RoamingType = RoamingType.PER_USER): InputStream?
/**
* You must close passed input stream.
@@ -41,5 +41,9 @@ public interface StreamProvider {
/**
* Delete file or directory
*/
- public fun delete(fileSpec: String, roamingType: RoamingType)
+ public fun delete(fileSpec: String, roamingType: RoamingType = RoamingType.PER_USER)
+}
+
+public fun StreamProvider.write(fileSpec: String, content: String) {
+ write(fileSpec, content.toByteArray())
}
\ No newline at end of file
diff --git a/plugins/settings-repository/src/BaseRepositoryManager.kt b/plugins/settings-repository/src/BaseRepositoryManager.kt
index 02cdabfbaf45..f0aa653ae19b 100644
--- a/plugins/settings-repository/src/BaseRepositoryManager.kt
+++ b/plugins/settings-repository/src/BaseRepositoryManager.kt
@@ -76,7 +76,16 @@ public abstract class BaseRepositoryManager(protected val dir: File) : Repositor
FileUtil.delete(dir)
}
+ protected open fun isPathIgnored(path: String): Boolean = false
+
override fun read(path: String): InputStream? {
+ if (isPathIgnored(path)) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("$path is ignored")
+ }
+ return null
+ }
+
var fileToDelete: File? = null
lock.read {
val file = File(dir, path)
@@ -104,6 +113,13 @@ public abstract class BaseRepositoryManager(protected val dir: File) : Repositor
}
override fun write(path: String, content: ByteArray, size: Int): Boolean {
+ if (isPathIgnored(path)) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("$path is ignored")
+ }
+ return false
+ }
+
if (LOG.isDebugEnabled()) {
LOG.debug("Write $path")
}
diff --git a/plugins/settings-repository/src/git/GitRepositoryManager.kt b/plugins/settings-repository/src/git/GitRepositoryManager.kt
index 7606baf63ee4..e63ca32c2e9a 100644
--- a/plugins/settings-repository/src/git/GitRepositoryManager.kt
+++ b/plugins/settings-repository/src/git/GitRepositoryManager.kt
@@ -67,7 +67,7 @@ class GitRepositoryManager(private val credentialsStore: NotNullLazyValue")
- provider.write("i/am/a/long/path/to/file/foo.html", "")
+ val filePaths = listOf("bar.html", "i/am/a/long/path/to/file/foo.html")
+ for (path in filePaths) {
+ provider.write(path, path)
+ }
val diff = repository.computeIndexDiff()
assertThat(diff.diff()).isFalse()
@@ -360,6 +363,10 @@ class GitTest : IcsTestCase() {
assertThat(diff.getModified()).isEmpty()
assertThat(diff.getUntracked()).isEmpty()
assertThat(diff.getUntrackedFolders()).isEmpty()
+
+ for (path in filePaths) {
+ assertThat(provider.read(path)).isNull()
+ }
}
private fun createRemoteRepository(branchName: String? = null, initialCommit: Boolean = true) {
diff --git a/plugins/settings-repository/testSrc/IcsTestCase.kt b/plugins/settings-repository/testSrc/IcsTestCase.kt
index 31b3f3810e0b..9f572f2d4a65 100644
--- a/plugins/settings-repository/testSrc/IcsTestCase.kt
+++ b/plugins/settings-repository/testSrc/IcsTestCase.kt
@@ -15,8 +15,6 @@
*/
package org.jetbrains.settingsRepository.test
-import com.intellij.configurationStore.StreamProvider
-import com.intellij.openapi.components.RoamingType
import com.intellij.testFramework.TemporaryDirectory
import com.intellij.testFramework.writeChild
import org.eclipse.jgit.lib.Repository
@@ -28,15 +26,6 @@ import org.junit.Rule
import java.nio.file.Path
import kotlin.properties.Delegates
-fun StreamProvider.write(path: String, data: ByteArray) {
- write(path, data, data.size(), RoamingType.PER_USER)
-}
-
-fun StreamProvider.write(fileSpec: String, content: String) {
- val data = content.toByteArray()
- write(fileSpec, data, data.size(), RoamingType.PER_USER)
-}
-
fun Repository.add(path: String, data: String) = add(path, data.toByteArray())
fun Repository.add(path: String, data: ByteArray): Repository {