diff options
author | Joey Hess <joey@kitenet.net> | 2012-08-10 16:00:24 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-08-10 16:00:24 -0400 |
commit | 21bd92f077c78320bd1ef2637962f53e97af40d1 (patch) | |
tree | c908420323115378250294dc75f015e8bb6f357e /Assistant/TransferQueue.hs | |
parent | 0d80406b2b94333c67c2a9da412fdacebf0eb780 (diff) |
send update notificaton when removing a queued transfer
Diffstat (limited to 'Assistant/TransferQueue.hs')
-rw-r--r-- | Assistant/TransferQueue.hs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/Assistant/TransferQueue.hs b/Assistant/TransferQueue.hs index 865a82915..24987bfa6 100644 --- a/Assistant/TransferQueue.hs +++ b/Assistant/TransferQueue.hs @@ -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 |