mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cds+ij - smarted CDS files cleanup, avoid retries after a failure
GitOrigin-RevId: 63507fb14228eab2ce47f2c2193bf9419d4171f8
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d8de2443b7
commit
0787f932fd
@@ -12,6 +12,7 @@ import com.intellij.openapi.util.text.StringUtil
|
||||
import com.sun.tools.attach.VirtualMachine
|
||||
import java.io.File
|
||||
import java.lang.management.ManagementFactory
|
||||
import java.time.Instant
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.system.measureTimeMillis
|
||||
|
||||
@@ -62,17 +63,17 @@ object CDSManager {
|
||||
}
|
||||
|
||||
fun cleanupStaleCDSFiles(indicator: ProgressIndicator) {
|
||||
val baseDir = CDSPaths.baseDir
|
||||
val paths = CDSPaths.current()
|
||||
val currentCDSPath = currentCDSArchive
|
||||
|
||||
val files = baseDir.listFiles() ?: arrayOf()
|
||||
val files = paths.baseDir.listFiles() ?: arrayOf()
|
||||
if (files.isEmpty()) return
|
||||
|
||||
indicator.text2 = "Removing old Class Data Sharing files..."
|
||||
for (path in files) {
|
||||
indicator.checkCanceled()
|
||||
|
||||
if (path != currentCDSPath) {
|
||||
if (path != currentCDSPath && !paths.isOurFile(path)) {
|
||||
FileUtil.delete(path)
|
||||
}
|
||||
}
|
||||
@@ -81,10 +82,16 @@ object CDSManager {
|
||||
fun installCDS(indicator: ProgressIndicator): CDSPaths? {
|
||||
val paths = CDSPaths.current()
|
||||
if (paths.isSame(currentCDSArchive)) {
|
||||
LOG.info("CDS archive is already generated. Nothing to do")
|
||||
LOG.warn("CDS archive is already generated. Nothing to do")
|
||||
return null
|
||||
}
|
||||
|
||||
if (paths.classesMarkerFile.isFile) {
|
||||
LOG.warn("CDS archive is already generated. The marker file exists")
|
||||
return null
|
||||
}
|
||||
paths.classesMarkerFile.writeText(Instant.now().toString())
|
||||
|
||||
LOG.info("Starting generation of CDS archive to the ${paths.classesArchiveFile} and ${paths.classesArchiveFile} files")
|
||||
|
||||
indicator.text2 = "Collecting classes list..."
|
||||
|
||||
@@ -9,16 +9,16 @@ import com.intellij.openapi.util.SystemInfo
|
||||
import java.io.File
|
||||
|
||||
|
||||
class CDSPaths private constructor(baseDir: File, cdsClassesHash: String) {
|
||||
class CDSPaths private constructor(val baseDir: File, cdsClassesHash: String) {
|
||||
val classesMarkerFile = File(baseDir, "${cdsClassesHash}.marker")
|
||||
val classesListFile = File(baseDir, "${cdsClassesHash}.txt")
|
||||
val classesPathFile = File(baseDir, "${cdsClassesHash}.classpath")
|
||||
val classesArchiveFile = File(baseDir, "${cdsClassesHash}.jsa")
|
||||
|
||||
fun isSame(jsaFile: File?) = jsaFile == classesArchiveFile
|
||||
fun isOurFile(file: File?) = file == classesMarkerFile || file == classesListFile || file == classesPathFile || file == classesArchiveFile
|
||||
|
||||
companion object {
|
||||
val baseDir: File get() = File(PathManager.getSystemPath(), "cds").also { it.mkdirs() }
|
||||
|
||||
fun current(): CDSPaths {
|
||||
val hasher = Hashing.sha256().newHasher()
|
||||
|
||||
@@ -38,6 +38,8 @@ class CDSPaths private constructor(baseDir: File, cdsClassesHash: String) {
|
||||
}
|
||||
|
||||
val cdsClassesHash = "${info.build.asString()}-${hasher.hash()}"
|
||||
val baseDir = File(PathManager.getSystemPath(), "cds")
|
||||
baseDir.mkdirs()
|
||||
return CDSPaths(baseDir, cdsClassesHash)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user