offset meters when resuming

This commit is contained in:
Joey Hess 2016-12-07 14:52:10 -04:00
parent 5ff85c8515
commit b55399e3ac
No known key found for this signature in database
GPG key ID: C910D9222512E3C7
2 changed files with 6 additions and 5 deletions

View file

@ -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

View file

@ -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