From dc08aeb67718d8fbe339ab51f0d7a1bf85fd597e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 7 Dec 2016 14:52:10 -0400 Subject: offset meters when resuming --- P2P/Protocol.hs | 8 +++++--- doc/todo/tor.mdwn | 3 +-- 2 files changed, 6 insertions(+), 5 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 diff --git a/doc/todo/tor.mdwn b/doc/todo/tor.mdwn index 1432c770e..af4fa1993 100644 --- a/doc/todo/tor.mdwn +++ b/doc/todo/tor.mdwn @@ -7,8 +7,7 @@ Current todo list: * copy --to peer seems to make the remotedaemon buffer the content in memory, more than I'd expect. * update progress logs in remotedaemon send/receive -* Resuming an interrupted download does not jump the progress to reflect - the amount already present. And, it fails at the end. +* Resuming an interrupted download fails at the end. * Think about locking some more. What happens if the connection to the peer is dropped while we think we're locking content there from being dropped? * merge to master -- cgit v1.2.3