stall detection is working

New config annex.stalldetection, remote.name.annex-stalldetection, which
can be used to deal with remotes that stall during transfers, or are
sometimes too slow to want to use.

This commit was sponsored by Luke Shumaker on Patreon.
This commit is contained in:
Joey Hess 2020-12-08 15:22:18 -04:00
parent 09ed9f7d1f
commit 41f2c308ff
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
11 changed files with 213 additions and 46 deletions

29
Types/StallDetection.hs Normal file
View file

@ -0,0 +1,29 @@
{- types for stall detection
-
- Copyright 2020 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
module Types.StallDetection where
import Utility.DataUnits
import Utility.HumanTime
import Utility.Misc
-- Unless the given number of bytes have been sent over the given
-- amount of time, there's a stall.
data StallDetection = StallDetection ByteSize Duration
deriving (Show)
-- Parse eg, "0KiB/60s"
parseStallDetection :: String -> Either String StallDetection
parseStallDetection s =
let (bs, ds) = separate (== '/') s
in do
b <- maybe
(Left $ "Unable to parse stall detection amount " ++ bs)
Right
(readSize dataUnits bs)
d <- parseDuration ds
return (StallDetection b d)