From 710f03c33378570f3aefd547fa48cfc8da0e46ce Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Wed, 2 Sep 2015 13:49:19 +0200 Subject: [PATCH] do not check if only format changed for non-roamable storage and default project --- .../configuration-store-impl/src/ComponentStoreImpl.kt | 4 ++-- .../src/DefaultProjectStoreImpl.kt | 2 ++ .../configuration-store-impl/src/ProjectStoreImpl.kt | 2 -- .../configuration-store-impl/src/XmlElementStorage.kt | 2 +- .../testSrc/ApplicationStoreTest.kt | 9 +++------ 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/platform/configuration-store-impl/src/ComponentStoreImpl.kt b/platform/configuration-store-impl/src/ComponentStoreImpl.kt index 5683648a6a49..e3b7c04a259c 100644 --- a/platform/configuration-store-impl/src/ComponentStoreImpl.kt +++ b/platform/configuration-store-impl/src/ComponentStoreImpl.kt @@ -248,7 +248,7 @@ abstract class ComponentStoreImpl : IComponentStore { } val storage = storageManager.getStateStorage(storageSpec) - var stateGetter = if (isUseLoadedStateAsExisting(storageSpec) && (ApplicationManager.getApplication().isUnitTestMode() || Registry.`is`("use.loaded.state.as.existing", false))) { + var stateGetter = if (isUseLoadedStateAsExisting(storage) && (ApplicationManager.getApplication().isUnitTestMode() || Registry.`is`("use.loaded.state.as.existing", false))) { (storage as? StorageBaseEx<*>)?.createGetSession(component, name, stateClass) } else { @@ -281,7 +281,7 @@ abstract class ComponentStoreImpl : IComponentStore { return name } - protected open fun isUseLoadedStateAsExisting(storageSpec: Storage): Boolean = true + protected open fun isUseLoadedStateAsExisting(storage: StateStorage): Boolean = (storage as? XmlElementStorage)?.roamingType != RoamingType.DISABLED protected open fun getPathMacroManagerForDefaults(): PathMacroManager? = null diff --git a/platform/configuration-store-impl/src/DefaultProjectStoreImpl.kt b/platform/configuration-store-impl/src/DefaultProjectStoreImpl.kt index a79feef438df..f8de1735d43e 100644 --- a/platform/configuration-store-impl/src/DefaultProjectStoreImpl.kt +++ b/platform/configuration-store-impl/src/DefaultProjectStoreImpl.kt @@ -77,6 +77,8 @@ class DefaultProjectStoreImpl(override val project: ProjectImpl, private val pat override fun getOldStorage(component: Any, componentName: String, operation: StateStorageOperation) = storage } + override fun isUseLoadedStateAsExisting(storage: StateStorage) = false + // don't want to optimize and use already loaded data - it will add unnecessary complexity and implementation-lock (currently we store loaded archived state in memory, but later implementation can be changed) fun getStateCopy() = storage.loadLocalData() diff --git a/platform/configuration-store-impl/src/ProjectStoreImpl.kt b/platform/configuration-store-impl/src/ProjectStoreImpl.kt index f3a5128b3aa6..5ca7c61f9f6c 100644 --- a/platform/configuration-store-impl/src/ProjectStoreImpl.kt +++ b/platform/configuration-store-impl/src/ProjectStoreImpl.kt @@ -288,8 +288,6 @@ open class ProjectStoreImpl(override val project: ProjectImpl, private val pathM } override fun selectDefaultStorages(storages: Array, operation: StateStorageOperation) = selectDefaultStorages(storages, operation, scheme) - - override fun isUseLoadedStateAsExisting(storageSpec: Storage) = storageSpec.file != StoragePathMacros.WORKSPACE_FILE } fun selectDefaultStorages(storages: Array, operation: StateStorageOperation, scheme: StorageScheme): Array { diff --git a/platform/configuration-store-impl/src/XmlElementStorage.kt b/platform/configuration-store-impl/src/XmlElementStorage.kt index 8d16a69a9585..90f158aed3e6 100644 --- a/platform/configuration-store-impl/src/XmlElementStorage.kt +++ b/platform/configuration-store-impl/src/XmlElementStorage.kt @@ -32,7 +32,7 @@ abstract class XmlElementStorage protected constructor(protected val fileSpec: S protected val pathMacroSubstitutor: TrackingPathMacroSubstitutor?, roamingType: RoamingType? = RoamingType.DEFAULT, provider: StreamProvider? = null) : StorageBaseEx() { - protected val roamingType: RoamingType = roamingType ?: RoamingType.DEFAULT + val roamingType: RoamingType = roamingType ?: RoamingType.DEFAULT private val provider: StreamProvider? = if (provider == null || roamingType == RoamingType.DISABLED || !provider.isApplicable(fileSpec, this.roamingType)) null else provider protected abstract fun loadLocalData(): Element? diff --git a/platform/configuration-store-impl/testSrc/ApplicationStoreTest.kt b/platform/configuration-store-impl/testSrc/ApplicationStoreTest.kt index 2120a265f162..ca28916b28f8 100644 --- a/platform/configuration-store-impl/testSrc/ApplicationStoreTest.kt +++ b/platform/configuration-store-impl/testSrc/ApplicationStoreTest.kt @@ -144,12 +144,12 @@ class ApplicationStoreTest { assertThat(file).hasContent("\n \n") } - @Test fun `do not apply to workspace storage - do not save if only format is changed`() { - @State(name = "A", storages = arrayOf(Storage(file = StoragePathMacros.WORKSPACE_FILE))) + @Test fun `do not check if only format changed for non-roamable storage`() { + @State(name = "A", storages = arrayOf(Storage(file = "b.xml", roamingType = RoamingType.DISABLED))) class AWorkspace : A() val oldContent = "" - val file = writeConfig("workspace.xml", oldContent) + val file = writeConfig("b.xml", oldContent) val oldModificationTime = file.getLastModifiedTime() testAppConfig.refreshVfs() @@ -206,10 +206,7 @@ class ApplicationStoreTest { override fun setPath(path: String) { storageManager.addMacro(StoragePathMacros.APP_CONFIG, path) - storageManager.addMacro(StoragePathMacros.WORKSPACE_FILE, "$path/workspace.xml") } - - override fun isUseLoadedStateAsExisting(storageSpec: Storage) = storageSpec.file != StoragePathMacros.WORKSPACE_FILE } abstract class Foo {