automatic stall detection
annex.stalldetection can now be set to "true" to make git-annex do automatic stall detection when it detects a remote is updating its transfer progress consistently enough. This commit was sponsored by Luke Shumaker on Patreon.
This commit is contained in:
parent
904689f11b
commit
135757d64a
8 changed files with 122 additions and 45 deletions
|
@ -1,6 +1,6 @@
|
|||
{- types for stall detection
|
||||
-
|
||||
- Copyright 2020 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2020-2021 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
@ -10,20 +10,32 @@ module Types.StallDetection where
|
|||
import Utility.DataUnits
|
||||
import Utility.HumanTime
|
||||
import Utility.Misc
|
||||
import Git.Config
|
||||
|
||||
-- Unless the given number of bytes have been sent over the given
|
||||
-- amount of time, there's a stall.
|
||||
data StallDetection = StallDetection ByteSize Duration
|
||||
data StallDetection
|
||||
= StallDetection ByteSize Duration
|
||||
-- ^ Unless the given number of bytes have been sent over the given
|
||||
-- amount of time, there's a stall.
|
||||
| ProbeStallDetection
|
||||
-- ^ Used when unsure how frequently transfer progress is updated,
|
||||
-- or how fast data can be sent.
|
||||
deriving (Show)
|
||||
|
||||
-- Parse eg, "0KiB/60s"
|
||||
parseStallDetection :: String -> Either String StallDetection
|
||||
parseStallDetection s =
|
||||
let (bs, ds) = separate (== '/') s
|
||||
in do
|
||||
--
|
||||
-- Also, it can be set to "true" (or other git config equivilants)
|
||||
-- to enable ProbeStallDetection.
|
||||
-- And "false" (and other git config equivilants) explicitly
|
||||
-- disable stall detection.
|
||||
parseStallDetection :: String -> Either String (Maybe StallDetection)
|
||||
parseStallDetection s = case isTrueFalse s of
|
||||
Nothing -> do
|
||||
let (bs, ds) = separate (== '/') s
|
||||
b <- maybe
|
||||
(Left $ "Unable to parse stall detection amount " ++ bs)
|
||||
Right
|
||||
(readSize dataUnits bs)
|
||||
d <- parseDuration ds
|
||||
return (StallDetection b d)
|
||||
return (Just (StallDetection b d))
|
||||
Just True -> Right (Just ProbeStallDetection)
|
||||
Just False -> Right Nothing
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue