diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSRecordsStorageKind.kt b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSRecordsStorageKind.kt index 7273fc92e6d5..650eaa7c08c5 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSRecordsStorageKind.kt +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/persistent/PersistentFSRecordsStorageKind.kt @@ -1,7 +1,6 @@ // Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.openapi.vfs.newvfs.persistent -import com.intellij.util.SystemProperties import com.intellij.util.io.IOUtil import com.intellij.util.io.PageCacheUtils import com.intellij.util.io.PagedFileStorageWithRWLockedPageContent @@ -12,41 +11,17 @@ import com.intellij.util.io.pagecache.impl.PageContentLockingStrategy import org.jetbrains.annotations.VisibleForTesting import java.io.IOException import java.nio.file.Path -import kotlin.io.path.exists enum class PersistentFSRecordsStorageKind : StorageFactory { /** Currently the default impl */ OVER_MMAPPED_FILE { - /** - * Fallback option: usually [PersistentFSConnector] deals with storages version changes just fine. - * But there are cases where it fails: e.g. with mmapped storages on Win, there file once mapped is hard - * to remove (and [PersistentFSConnector] relies on ability to just remove legacy storages files). - * In such cases, this option could help get rid of the legacy file early, before it is mapped - * MAYBE RC: we probably outgrow that issues: - * a) it's been 2 releases since we moved to memory-mapped for fs-records, i.e. everybody who could have this - * problem -- already has fixed it - * b) i've done a lot for memory-mapped files to work properly on Windows also - */ - private val FAIL_EARLY_IF_LEGACY_STORAGE_DETECTED: Boolean = SystemProperties.getBooleanProperty( - "vfs.fail-early-if-legacy-storage-detected", false) - override fun open(storagePath: Path): PersistentFSRecordsLockFreeOverMMappedFile { - //TODO RC: this should be replaced with/encapsulated into StorageFactory - if (FAIL_EARLY_IF_LEGACY_STORAGE_DETECTED) { - val legacyLengthFile = storagePath.resolveSibling(storagePath.fileName.toString() + ".len") - if (legacyLengthFile.exists()) { - //MAYBE RC: actually, here we can _migrate_ legacy file to the new format: move the files to the tmp folder, - // create empty new storage, and just copy all records from legacy storage to the new one... - throw IOException("Legacy records file detected (${legacyLengthFile} exists): VFS rebuild required") - } + override fun open(storagePath: Path): PersistentFSRecordsLockFreeOverMMappedFile = MMappedFileStorageFactory.withDefaults() + .pageSize(PersistentFSRecordsLockFreeOverMMappedFile.DEFAULT_MAPPED_CHUNK_SIZE) + .wrapStorageSafely(storagePath) { storage -> + PersistentFSRecordsLockFreeOverMMappedFile(storage) } - return MMappedFileStorageFactory.withDefaults() - .pageSize(PersistentFSRecordsLockFreeOverMMappedFile.DEFAULT_MAPPED_CHUNK_SIZE) - .wrapStorageSafely(storagePath) { storage -> - PersistentFSRecordsLockFreeOverMMappedFile(storage) - } - } }, /** Fallback impl for [OVER_MMAPPED_FILE] if something goes terribly wrong, and we can't fix it quickly */