@@ -94,6 +94,7 @@ data Details =
95verify :: Stuff.PackageCache -> Connection -> Registry.Registry -> Map.Map Pkg.Name C.Constraint -> IO (Result (Map.Map Pkg.Name Details))
95verify :: Stuff.PackageCache -> Connection -> Registry.Registry -> Map.Map Pkg.Name C.Constraint -> IO (Result (Map.Map Pkg.Name Details))
96verify cache connection registry constraints =
96verify cache connection registry constraints =
97+ Stuff.withRegistryLock cache $
97 case try constraints of
98 case try constraints of
98 Solver solver ->
99 Solver solver ->
99 solver (State cache connection registry Map.empty)
100 solver (State cache connection registry Map.empty)
@@ -130,6 +131,7 @@ data AppSolution =
131addToApp :: Stuff.PackageCache -> Connection -> Registry.Registry -> Pkg.Name -> Outline.AppOutline -> IO (Result AppSolution)
132addToApp :: Stuff.PackageCache -> Connection -> Registry.Registry -> Pkg.Name -> Outline.AppOutline -> IO (Result AppSolution)
132addToApp cache connection registry pkg outline@(Outline.AppOutline _ _ direct indirect testDirect testIndirect) =
133addToApp cache connection registry pkg outline@(Outline.AppOutline _ _ direct indirect testDirect testIndirect) =
134+ Stuff.withRegistryLock cache $
134 allIndirects = Map.union indirect testIndirect
136 allIndirects = Map.union indirect testIndirect
135 allDirects = Map.union direct testDirect
137 allDirects = Map.union direct testDirect
@@ -349,30 +351,31 @@ data Env =
350initEnv :: IO (Either Exit.RegistryProblem Env)
352initEnv :: IO (Either Exit.RegistryProblem Env)
352− Stuff.withRegistryLock $ \cache ->
353− do mvar <- newEmptyMVar
354+ do mvar <- newEmptyMVar
354− _ <- forkIO $ putMVar mvar =<< Http.getManager
355+ _ <- forkIO $ putMVar mvar =<< Http.getManager
356+ cache <- Stuff.getPackageCache
357+ Stuff.withRegistryLock cache $
355− maybeRegistry <- Registry.read cache
358+ do maybeRegistry <- Registry.read cache
356− manager <- readMVar mvar
359+ manager <- readMVar mvar
358− case maybeRegistry of
361+ case maybeRegistry of
359− Nothing ->
362+ Nothing ->
360− do eitherRegistry <- Registry.fetch manager cache
363+ do eitherRegistry <- Registry.fetch manager cache
361− case eitherRegistry of
364+ case eitherRegistry of
362− Right latestRegistry ->
365+ Right latestRegistry ->
363− return $ Right $ Env cache manager (Online manager) latestRegistry
366+ return $ Right $ Env cache manager (Online manager) latestRegistry
365− Left problem ->
368+ Left problem ->
366− return $ Left $ problem
369+ return $ Left $ problem
368− Just cachedRegistry ->
371+ Just cachedRegistry ->
369− do eitherRegistry <- Registry.update manager cache cachedRegistry
372+ do eitherRegistry <- Registry.update manager cache cachedRegistry
370− case eitherRegistry of
373+ case eitherRegistry of
371− Right latestRegistry ->
374+ Right latestRegistry ->
372− return $ Right $ Env cache manager (Online manager) latestRegistry
375+ return $ Right $ Env cache manager (Online manager) latestRegistry
374− Left _ ->
377+ Left _ ->
375− return $ Right $ Env cache manager Offline cachedRegistry
378+ return $ Right $ Env cache manager Offline cachedRegistry