in src/main/scala/org/jetbrains/plugins/scala/indices/protocol/sbt/Locking.scala [14:33]
def lockFile(compilationInfoDir: File): File =
new File(compilationInfoDir, ".sbt-idea-lock")
def lock(lockFile: File)(log: Logger = noopLogger): FileLock = {
if (lockFile.getParentFile.exists() || lockFile.getParentFile.mkdirs()) {
val raf = new RandomAccessFile(lockFile, "rw")
try {
log(s"Acquiring lock on file $lockFile ...")
val lock = raf.getChannel.lock()
locks.put(lockFile, LockData(raf, lock))
lock
}
catch {
case e: IOException =>
raf.close()
throw e
}
} else throw new RuntimeException("Unable to create lock file.")
}