send update notificaton when removing a queued transfer

This commit is contained in:
Joey Hess 2012-08-10 16:00:24 -04:00
parent 0d80406b2b
commit 21bd92f077
2 changed files with 20 additions and 14 deletions

View file

@ -136,9 +136,13 @@ getNextTransfer q dstatus acceptable = atomically $ do
{- Removes a transfer from the queue, if present, and returns True if it
- was present. -}
dequeueTransfer :: TransferQueue -> Transfer -> IO Bool
dequeueTransfer q t = atomically $ do
(l, removed) <- partition (\i -> fst i /= t) <$> readTVar (queuelist q)
void $ writeTVar (queuesize q) (length l)
void $ writeTVar (queuelist q) l
return $ not $ null 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)
void $ writeTVar (queuesize q) (length l)
void $ writeTVar (queuelist q) l
return $ not $ null removed
when ok $
notifyTransfer dstatus
return ok