@@ -188,29 +188,29 @@ object KiteCompilationConfiguration : ScriptCompilationConfiguration({
188188
189189 hostConfiguration(ScriptingHostConfiguration {
190190 jvm {
191- // Creating directories in case they don't exist yet .
192- if ( Kite . Structure . CACHE_DIR .isDirectory || Kite . Structure . CACHE_DIR .mkdirs()) {
193- // Configuring compilation cache.
194- compilationCache( CompiledScriptJarsCache { script, compilationConfiguration ->
195- val name = compilationConfiguration[displayName]
196- val checksum = MessageDigest .getInstance(" MD5 ")
197- // Getting the MD5 checksum and including it in the file name.
198- // MD5 checksum acts as a file identifier here .
199- checksum.update(script.text.toByteArray())
200- // Updating digest with all imported scripts.
201- importsCache.cache[name]?.forEach {
202- checksum.update( File (it).readBytes())
203- }
204- // Converting checksum to a human-readable format so it can be included in the cache file name.
205- val hash = checksum.digest().joinToString("") { "%02x".format(it) }
206- val cacheFileName = "$name.$hash.cache.jar"
207- // Purging old cache files with different hashes (not the current one).
208- Kite . Structure . CACHE_DIR .listFiles()
209- ?.filter { it.name.endsWith(".cache.jar") && it.name.split(".").first() == name && it.name != cacheFileName }
210- ?.forEach { it.delete() }
211- return@ CompiledScriptJarsCache Kite . Structure . CACHE_DIR .resolve(cacheFileName)
212- } )
213- }
191+ // Configuring compilation cache .
192+ compilationCache( CompiledScriptJarsCache { script, compilationConfiguration ->
193+ // Creating cache directory in case it does not exist .
194+ Kite . Structure . CACHE_DIR .mkdirs()
195+ // Creating directories in case they don't exist yet.
196+ val name = compilationConfiguration[displayName]
197+ val checksum = MessageDigest .getInstance(" MD5 ")
198+ // Getting the MD5 checksum and including it in the file name .
199+ // MD5 checksum acts as a file identifier here.
200+ checksum.update(script.text.toByteArray())
201+ // Updating digest with all imported scripts.
202+ importsCache.cache[name]?.forEach {
203+ checksum.update( File (it).readBytes())
204+ }
205+ // Converting checksum to a human-readable format so it can be included in the cache file name.
206+ val hash = checksum.digest().joinToString("") { "%02x".format(it) }
207+ val cacheFileName = "$name.$hash. cache.jar"
208+ // Purging old cache files with different hashes (not the current one).
209+ Kite . Structure . CACHE_DIR .listFiles()
210+ ?.filter { it.name.endsWith(".cache.jar") && it.name.split(".").first() == name && it.name != cacheFileName }
211+ ?.forEach { it.delete() }
212+ return@ CompiledScriptJarsCache Kite . Structure . CACHE_DIR .resolve(cacheFileName )
213+ })
214214 }
215215 })
216216})
0 commit comments