[IC] Add methods to write without explicit registering in a transaction
#KT-49785 In Progress
This commit is contained in:
committed by
Space Team
parent
581bc89849
commit
3dcf5af4b0
@@ -37,6 +37,24 @@ interface CompilationTransaction : Closeable {
|
||||
fun markAsSuccessful()
|
||||
}
|
||||
|
||||
fun CompilationTransaction.write(file: Path, writeAction: () -> Unit) {
|
||||
registerAddedOrChangedFile(file)
|
||||
writeAction()
|
||||
}
|
||||
|
||||
fun CompilationTransaction.writeText(file: Path, text: String) {
|
||||
writeBytes(file, text.toByteArray())
|
||||
}
|
||||
|
||||
fun CompilationTransaction.writeBytes(file: Path, array: ByteArray) {
|
||||
write(file) {
|
||||
if (!Files.exists(file.parent)) {
|
||||
Files.createDirectories(file.parent)
|
||||
}
|
||||
Files.write(file, array)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A dummy implementation of compilation transaction
|
||||
*/
|
||||
|
||||
@@ -72,9 +72,7 @@ open class IncrementalJsCache(
|
||||
var header: ByteArray
|
||||
get() = headerFile.readBytes()
|
||||
set(value) {
|
||||
icContext.transaction.registerAddedOrChangedFile(headerFile.toPath())
|
||||
cachesDir.mkdirs()
|
||||
headerFile.writeBytes(value)
|
||||
icContext.transaction.writeBytes(headerFile.toPath(), value)
|
||||
}
|
||||
|
||||
override fun markDirty(removedAndCompiledSources: Collection<File>) {
|
||||
|
||||
@@ -148,13 +148,7 @@ open class LookupStorage(
|
||||
try {
|
||||
if (size != oldSize) {
|
||||
if (size > 0) {
|
||||
icContext.transaction.registerAddedOrChangedFile(countersFile.toPath())
|
||||
if (!countersFile.exists()) {
|
||||
countersFile.parentFile.mkdirs()
|
||||
countersFile.createNewFile()
|
||||
}
|
||||
|
||||
countersFile.writeText("$size\n0")
|
||||
icContext.transaction.writeText(countersFile.toPath(), "$size\n0")
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user