KSCM: fix wrong update on null return from Template.getDependenciesFor
This commit is contained in:
+8
-10
@@ -224,7 +224,7 @@ class KotlinScriptConfigurationManager(
|
|||||||
val currentTimeStamp = TimeStamps.next()
|
val currentTimeStamp = TimeStamps.next()
|
||||||
val scriptContents = scriptDefinition.makeScriptContents(file, project)
|
val scriptContents = scriptDefinition.makeScriptContents(file, project)
|
||||||
val newFuture = supplyAsync(Supplier {
|
val newFuture = supplyAsync(Supplier {
|
||||||
val newDependencies = scriptDefinition.getDependenciesFor(oldDataAndRequest?.dependencies, scriptContents)
|
val newDependencies = scriptDefinition.getDependenciesFor(oldDataAndRequest?.dependencies, scriptContents) ?: EmptyDependencies
|
||||||
cacheLock.read {
|
cacheLock.read {
|
||||||
val lastTimeStamp = cache[path]?.requestInProgress?.timeStamp
|
val lastTimeStamp = cache[path]?.requestInProgress?.timeStamp
|
||||||
if (lastTimeStamp == currentTimeStamp) {
|
if (lastTimeStamp == currentTimeStamp) {
|
||||||
@@ -254,31 +254,27 @@ class KotlinScriptConfigurationManager(
|
|||||||
private fun <TF : Any> updateSync(file: TF, scriptDef: KotlinScriptDefinition): Boolean {
|
private fun <TF : Any> updateSync(file: TF, scriptDef: KotlinScriptDefinition): Boolean {
|
||||||
val path = getFilePath(file)
|
val path = getFilePath(file)
|
||||||
val oldDeps = cache[path]?.dependencies
|
val oldDeps = cache[path]?.dependencies
|
||||||
val deps = scriptDef.getDependenciesFor(file, project, oldDeps)
|
val deps = scriptDef.getDependenciesFor(file, project, oldDeps) ?: EmptyDependencies
|
||||||
return cacheSync(deps, oldDeps, path, file as? VirtualFile)
|
return cacheSync(deps, oldDeps, path, file as? VirtualFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun cacheSync(
|
private fun cacheSync(
|
||||||
new: KotlinScriptExternalDependencies?,
|
new: KotlinScriptExternalDependencies,
|
||||||
old: KotlinScriptExternalDependencies?,
|
old: KotlinScriptExternalDependencies?,
|
||||||
path: String,
|
path: String,
|
||||||
file: VirtualFile?
|
file: VirtualFile?
|
||||||
): Boolean {
|
): Boolean {
|
||||||
return when {
|
return when {
|
||||||
new != null && (old == null || !(new.match(old))) -> {
|
old == null || !(new.match(old)) -> {
|
||||||
// changed or new
|
// changed or new
|
||||||
save(path, new, file, persist = true)
|
save(path, new, file, persist = true)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
new != null -> {
|
else -> {
|
||||||
save(path, new, file, persist = false)
|
save(path, new, file, persist = false)
|
||||||
|
// same
|
||||||
false
|
false
|
||||||
} // same
|
|
||||||
cache.remove(path) != null -> {
|
|
||||||
save(path, null, file, persist = true)
|
|
||||||
true
|
|
||||||
}
|
}
|
||||||
else -> false // unknown
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,3 +380,5 @@ object TimeStamps {
|
|||||||
|
|
||||||
fun next() = TimeStamp(current++)
|
fun next() = TimeStamp(current++)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private object EmptyDependencies: KotlinScriptExternalDependencies
|
||||||
Reference in New Issue
Block a user