diff options
author | Joey Hess <joey@kitenet.net> | 2013-04-02 16:17:06 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-04-02 16:17:06 -0400 |
commit | c150b05386e97ddaa1162a0943312223c94a225b (patch) | |
tree | b9253fa12ffa70dde092c19d8b13536b404b72bf /Assistant/TransferQueue.hs | |
parent | ec8571ee6d5484dd32f93bf0cebeb2983723d4fb (diff) |
avoid queuing transfers that are currently running
Diffstat (limited to 'Assistant/TransferQueue.hs')
-rw-r--r-- | Assistant/TransferQueue.hs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/Assistant/TransferQueue.hs b/Assistant/TransferQueue.hs index 0afe3cb19..ac9ed3216 100644 --- a/Assistant/TransferQueue.hs +++ b/Assistant/TransferQueue.hs @@ -136,14 +136,18 @@ enqueue reason schedule t info notifyTransfer add modlist = do q <- getAssistant transferQueue - liftIO $ atomically $ do - l <- readTVar (queuelist q) - if (t `notElem` map fst l) - then do - void $ modifyTVar' (queuesize q) succ - void $ modifyTVar' (queuelist q) modlist - return True - else return False + dstatus <- getAssistant daemonStatusHandle + liftIO $ atomically $ ifM (checkRunningTransferSTM dstatus t) + ( return False + , do + l <- readTVar (queuelist q) + if (t `notElem` map fst l) + then do + void $ modifyTVar' (queuesize q) succ + void $ modifyTVar' (queuelist q) modlist + return True + else return False + ) {- Adds a transfer to the queue. -} queueTransfer :: Reason -> Schedule -> AssociatedFile -> Transfer -> Remote -> Assistant () |