increase number of capabilities to match -Jn setting
authorJoey Hess <joeyh@joeyh.name>
Thu, 5 Nov 2015 23:57:41 +0000 (19:57 -0400)
committerJoey Hess <joeyh@joeyh.name>
Thu, 5 Nov 2015 23:57:41 +0000 (19:57 -0400)
CmdLine/GitAnnex/Options.hs

index b004e4239814947189d45092df894c262dac0f6e..7d8bcadeeb2411c3a045c29a2dd88110d2b84b53 100644 (file)
@@ -9,6 +9,7 @@ module CmdLine.GitAnnex.Options where
 
 import Options.Applicative
 import Options.Applicative.Builder.Internal
+import Control.Concurrent
 
 import Common.Annex
 import qualified Git.Config
@@ -292,7 +293,11 @@ jobsOption = globalSetter set $
                <> hidden
                )
   where
-       set n = Annex.changeState $ \s -> s { Annex.concurrentjobs = Just n }
+       set n = do
+               Annex.changeState $ \s -> s { Annex.concurrentjobs = Just n }
+               c <- liftIO getNumCapabilities
+               when (n > c) $
+                       liftIO $ setNumCapabilities n
 
 timeLimitOption :: GlobalOption
 timeLimitOption = globalSetter Limit.addTimeLimit $ strOption