mirror of https://github.com/sbt/sbt.git
fix GlobalLock behavior when lock file's directory does not exist
This commit is contained in:
parent
586650d7a9
commit
d01be91844
|
|
@ -9,7 +9,12 @@ object Locks extends xsbti.GlobalLock
|
|||
{
|
||||
private[this] val locks = new Cache[File, GlobalLock](new GlobalLock(_))
|
||||
def apply[T](file: File, action: Callable[T]): T =
|
||||
synchronized { locks(file.getCanonicalFile).withLock(action) }
|
||||
synchronized
|
||||
{
|
||||
file.getParentFile.mkdirs()
|
||||
file.createNewFile()
|
||||
locks(file.getCanonicalFile).withLock(action)
|
||||
}
|
||||
|
||||
private[this] class GlobalLock(file: File)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
package xsbt.boot
|
||||
|
||||
import org.scalacheck._
|
||||
import Prop._
|
||||
import java.io.File
|
||||
|
||||
object LocksTest extends Properties("Locks")
|
||||
{
|
||||
property("Lock in nonexisting directory") =
|
||||
FileUtilities.withTemporaryDirectory { dir =>
|
||||
val lockFile = new File(dir, "doesntexist/lock")
|
||||
Locks(lockFile, new java.util.concurrent.Callable[Boolean] { def call = true })
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue