simplify annex.bwlimit handling
authorJoey Hess <joeyh@joeyh.name>
Wed, 22 Sep 2021 14:51:10 +0000 (10:51 -0400)
committerJoey Hess <joeyh@joeyh.name>
Wed, 22 Sep 2021 14:52:01 +0000 (10:52 -0400)
RemoteGitConfig parsing looks for annex.bwlimit when a remote
does not have a per-remote config for it, so no need for a separate
gobal config.

Sponsored-by: Svenne Krap on Patreon
Annex/Import.hs
Annex/Transfer.hs
Remote/Git.hs
Remote/Helper/P2P.hs
Remote/Helper/Special.hs
Types/GitConfig.hs

index 010808ef3f97c6baa7bb5b99437dd6a9b8fb1976..2d15c11b99849d2f91a4ea46758ccfbe4457e393 100644 (file)
@@ -461,7 +461,7 @@ importKeys remote importtreeconfig importcontent thirdpartypopulated importablec
                                        , providedMimeEncoding = Nothing
                                        , providedLinkType = Nothing
                                        }
-                               bwlimit <- bwLimit (Remote.gitconfig remote)
+                               let bwlimit = remoteAnnexBwLimit (Remote.gitconfig remote)
                                islargefile <- checkMatcher' matcher mi mempty
                                metered Nothing sz bwlimit $ const $ if islargefile
                                        then doimportlarge importkey cidmap db loc cid sz f
@@ -558,7 +558,7 @@ importKeys remote importtreeconfig importcontent thirdpartypopulated importablec
                        Left e -> do
                                warning (show e)
                                return Nothing
-               bwlimit <- bwLimit (Remote.gitconfig remote)
+               let bwlimit = remoteAnnexBwLimit (Remote.gitconfig remote)
                checkDiskSpaceToGet tmpkey Nothing $
                        notifyTransfer Download af $
                                download' (Remote.uuid remote) tmpkey af Nothing stdRetry $ \p ->
index b0d53a66a3d0fd84673b791beaf1053580725d57..c6597baec26b44edb2df453937dccd7b001921f2 100644 (file)
@@ -19,7 +19,6 @@ module Annex.Transfer (
        noRetry,
        stdRetry,
        pickRemote,
-       bwLimit,
 ) where
 
 import Annex.Common
@@ -402,9 +401,3 @@ lessActiveFirst :: M.Map Remote Integer -> Remote -> Remote -> Ordering
 lessActiveFirst active a b
        | Remote.cost a == Remote.cost b = comparing (`M.lookup` active) a b
        | otherwise = comparing Remote.cost a b
-
-bwLimit :: RemoteGitConfig -> Annex (Maybe BwRate)
-bwLimit gc = maybe globalcfg (pure . Just) remotecfg
-  where
-       globalcfg = annexBwLimit <$> Annex.getGitConfig
-       remotecfg = remoteAnnexBwLimit gc
index 65d388bf9212218a71f44e7a878e820ecf589429..7f615d114ecdc375c015063b2c90ad8b77a74c1d 100644 (file)
@@ -550,7 +550,7 @@ copyFromRemote'' repo forcersync r st@(State connpool _ _ _ _) key file dest met
        | not $ Git.repoIsUrl repo = guardUsable repo (giveup "cannot access remote") $ do
                u <- getUUID
                hardlink <- wantHardLink
-               bwlimit <- bwLimit (gitconfig r)
+               let bwlimit = remoteAnnexBwLimit (gitconfig r)
                -- run copy from perspective of remote
                onLocalFast st $ Annex.Content.prepSendAnnex' key >>= \case
                        Just (object, check) -> do
@@ -696,7 +696,7 @@ copyToRemote' repo r st@(State connpool duc _ _ _) key file meterupdate
                checkio <- Annex.withCurrentState check
                u <- getUUID
                hardlink <- wantHardLink
-               bwlimit <- bwLimit (gitconfig r)
+               let bwlimit = remoteAnnexBwLimit (gitconfig r)
                -- run copy from perspective of remote
                res <- onLocalFast st $ ifM (Annex.Content.inAnnex key)
                        ( return True
index 0a9d41b9de4b3d377a1b1450068b33c00371e68b..2dd641a67ed243f0dfdfcd7cc7a308e876101ce1 100644 (file)
@@ -18,7 +18,6 @@ import Messages.Progress
 import Utility.Metered
 import Types.NumCopies
 import Annex.Verify
-import Annex.Transfer
 
 import Control.Concurrent
 
@@ -35,7 +34,7 @@ type WithConn a c = (ClosableConnection c -> Annex (ClosableConnection c, a)) ->
 store :: RemoteGitConfig -> (MeterUpdate -> ProtoRunner Bool) -> Key -> AssociatedFile -> MeterUpdate -> Annex ()
 store gc runner k af p = do
        let sizer = KeySizer k (fmap (toRawFilePath . fst) <$> prepSendAnnex k)
-       bwlimit <- bwLimit gc
+       let bwlimit = remoteAnnexBwLimit gc
        metered (Just p) sizer bwlimit $ \_ p' ->
                runner p' (P2P.put k af p') >>= \case
                        Just True -> return ()
@@ -45,7 +44,7 @@ store gc runner k af p = do
 retrieve :: RemoteGitConfig -> (MeterUpdate -> ProtoRunner (Bool, Verification)) -> Key -> AssociatedFile -> FilePath -> MeterUpdate -> VerifyConfig -> Annex Verification
 retrieve gc runner k af dest p verifyconfig = do
        iv <- startVerifyKeyContentIncrementally verifyconfig k
-       bwlimit <- bwLimit gc
+       let bwlimit = remoteAnnexBwLimit gc
        metered (Just p) k bwlimit $ \m p' -> 
                runner p' (P2P.get dest k iv af m p') >>= \case
                        Just (True, v) -> return v
index d221be040ee729ddf3c747ae1c908e2d7d1ec260..8f595865db35b63d54956c015ea7214422bed3ca 100644 (file)
@@ -42,7 +42,6 @@ import Types.StoreRetrieve
 import Types.Remote
 import Annex.Verify
 import Annex.UUID
-import Annex.Transfer
 import Config
 import Config.Cost
 import Utility.Metered
@@ -263,7 +262,7 @@ specialRemote' cfg c storer retriever remover checkpresent baser = encr
 
        displayprogress p k srcfile a
                | displayProgress cfg = do
-                       bwlimit <- bwLimit (gitconfig baser)
+                       let bwlimit = remoteAnnexBwLimit (gitconfig baser)
                        metered (Just p) (KeySizer k (pure (fmap toRawFilePath srcfile))) bwlimit (const a)
                | otherwise = a p
 
index fca052da4e65f5d15712dbe6f5434ab0167eb106..affc7f01461a71685adabbaf554f3366e3cc83d4 100644 (file)
@@ -123,7 +123,6 @@ data GitConfig = GitConfig
        , annexRetry :: Maybe Integer
        , annexForwardRetry :: Maybe Integer
        , annexRetryDelay :: Maybe Seconds
-       , annexBwLimit :: Maybe BwRate
        , annexAllowedUrlSchemes :: S.Set Scheme
        , annexAllowedIPAddresses :: String
        , annexAllowUnverifiedDownloads :: Bool
@@ -217,9 +216,6 @@ extractGitConfig configsource r = GitConfig
        , annexForwardRetry = getmayberead (annexConfig "forward-retry")
        , annexRetryDelay = Seconds
                <$> getmayberead (annexConfig "retrydelay")
-       , annexBwLimit =
-               either (const Nothing) Just . parseBwRate
-                       =<< getmaybe (annexConfig "bwlimit")
        , annexAllowedUrlSchemes = S.fromList $ map mkScheme $
                maybe ["http", "https", "ftp"] words $
                        getmaybe (annexConfig "security.allowed-url-schemes")