aboutsummaryrefslogtreecommitdiff
path: root/Assistant/TransferQueue.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-08-29 15:24:09 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-08-29 15:24:09 -0400
commit99525f8454ecdcc41b37d8fcae83502ea5044d43 (patch)
treee0e5d0b20fd0e4556fb6d23a3e62a97d3a229319 /Assistant/TransferQueue.hs
parent9e54355e8b6751f6ce786da480566e27fb5996d8 (diff)
when canceling a transfer, also cancel all other downloads of the same key
Diffstat (limited to 'Assistant/TransferQueue.hs')
-rw-r--r--Assistant/TransferQueue.hs7
1 files changed, 4 insertions, 3 deletions
diff --git a/Assistant/TransferQueue.hs b/Assistant/TransferQueue.hs
index fe2c667f9..2b6f1d20e 100644
--- a/Assistant/TransferQueue.hs
+++ b/Assistant/TransferQueue.hs
@@ -140,12 +140,13 @@ getNextTransfer q dstatus acceptable = atomically $ do
return $ Just r
else return Nothing
-{- Removes a transfer from the queue, if present, and returns True if it
- - was present. -}
+{- Removes a transfer (as well as any equivilant transfers) from the queue,
+ - and returns True if anything was removed. -}
dequeueTransfer :: TransferQueue -> DaemonStatusHandle -> Transfer -> IO Bool
dequeueTransfer q dstatus t = do
ok <- atomically $ do
- (l, removed) <- partition (\i -> fst i /= t) <$> readTVar (queuelist q)
+ (removed, l) <- partition (equivilantTransfer t . fst)
+ <$> readTVar (queuelist q)
void $ writeTVar (queuesize q) (length l)
void $ writeTVar (queuelist q) l
return $ not $ null removed