@@ -9,6 +9,8 @@ module Stuff
10 , findRoot
10 , findRoot
11 , withRootLock
11 , withRootLock
12 , PackageCache
14 , PackageCache
13 , getPackageCache
15 , getPackageCache
14 , registry
16 , registry
@@ -123,7 +125,18 @@ withRootLock :: FilePath -> IO a -> IO a
123withRootLock root work =
125withRootLock root work =
124 do let dir = stuff root
126 do let dir = stuff root
125 Dir.createDirectoryIfMissing True dir
127 Dir.createDirectoryIfMissing True dir
126− Lock.withFileLock (dir </> "project.lock") Lock.Exclusive (\_ -> work)
128+ Lock.withFileLock (dir </> "lock") Lock.Exclusive (\_ -> work)
131+withRegistryLock :: (PackageCache -> IO a) -> IO a
132+withRegistryLock callback =
133+ do cache@(PackageCache dir) <- getPackageCache
134+ Lock.withFileLock (dir </> "lock") Lock.Exclusive (\_ -> callback cache)
137+withPackageLock :: PackageCache -> Pkg.Name -> V.Version -> IO a -> IO a
138+withPackageLock cache pkg vsn work =
139+ Lock.withFileLock (package cache pkg vsn </> "lock") Lock.Exclusive (\_ -> work)