[vfs][cleanup] remove legacy fs-records format detection

+ 231 was the last version with non-mmapped default fs records impl --full year passed, no need to keep legacy storage detection anymore

GitOrigin-RevId: 6a883fb1c69bf914239e2de7235815a2bcf977d6
This commit is contained in:
Ruslan Cheremin
2024-03-25 23:31:00 +00:00
committed by intellij-monorepo-bot
parent c5108950a1
commit 311414d181
@@ -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<PersistentFSRecordsStorage> {
/** 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<PersistentFSStorage>
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<PersistentFSRecordsLockFreeOverMMappedFile, IOException>(storagePath) { storage ->
PersistentFSRecordsLockFreeOverMMappedFile(storage)
}
return MMappedFileStorageFactory.withDefaults()
.pageSize(PersistentFSRecordsLockFreeOverMMappedFile.DEFAULT_MAPPED_CHUNK_SIZE)
.wrapStorageSafely<PersistentFSRecordsLockFreeOverMMappedFile, IOException>(storagePath) { storage ->
PersistentFSRecordsLockFreeOverMMappedFile(storage)
}
}
},
/** Fallback impl for [OVER_MMAPPED_FILE] if something goes terribly wrong, and we can't fix it quickly */