aboutsummaryrefslogtreecommitdiff
path: root/P2P
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-12-07 14:52:10 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-12-07 14:52:10 -0400
commitdc08aeb67718d8fbe339ab51f0d7a1bf85fd597e (patch)
treea4721073f113a28a78dd83434ccbb1d92a2bd6f7 /P2P
parentf9ef5a66ef70d68873c3514b8a634f9bed43fe8b (diff)
offset meters when resuming
Diffstat (limited to 'P2P')
-rw-r--r--P2P/Protocol.hs8
1 files changed, 5 insertions, 3 deletions
diff --git a/P2P/Protocol.hs b/P2P/Protocol.hs
index b1e2bf481..f51ea7f98 100644
--- a/P2P/Protocol.hs
+++ b/P2P/Protocol.hs
@@ -379,22 +379,24 @@ serveAuthed myuuid = void $ serverLoop handler
handler _ = return ServerUnexpected
sendContent :: Key -> AssociatedFile -> Offset -> MeterUpdate -> Proto Bool
-sendContent key af offset p = do
+sendContent key af offset@(Offset n) p = do
+ let p' = offsetMeterUpdate p (toBytesProcessed n)
(len, content) <- readContentLen key af offset
net $ sendMessage (DATA len)
- net $ sendBytes len content p
+ net $ sendBytes len content p'
checkSuccess
receiveContent :: MeterUpdate -> Local Len -> (Offset -> Len -> L.ByteString -> Local Bool) -> (Offset -> Message) -> Proto Bool
receiveContent p sizer storer mkmsg = do
Len n <- local sizer
+ let p' = offsetMeterUpdate p (toBytesProcessed n)
let offset = Offset n
net $ sendMessage (mkmsg offset)
r <- net receiveMessage
case r of
DATA len -> do
ok <- local . storer offset len
- =<< net (receiveBytes len p)
+ =<< net (receiveBytes len p')
sendSuccess ok
return ok
_ -> do