diff options
author | Joey Hess <joey@kitenet.net> | 2012-10-29 17:02:50 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-10-29 17:02:50 -0400 |
commit | 37d888f9b4a33933b2e894791ed85647c02e6182 (patch) | |
tree | 71e7773f31bb8bdbda31fd1731d543e372a11dae | |
parent | 2960a8011484fa3dad1cff55e8e412f4d4b1db84 (diff) |
tweak
-rw-r--r-- | Assistant/DaemonStatus.hs | 4 | ||||
-rw-r--r-- | Assistant/Monad.hs | 3 | ||||
-rw-r--r-- | Assistant/Threads/TransferPoller.hs | 5 | ||||
-rw-r--r-- | Assistant/Threads/TransferWatcher.hs | 6 |
4 files changed, 11 insertions, 7 deletions
diff --git a/Assistant/DaemonStatus.hs b/Assistant/DaemonStatus.hs index 49586754c..44547fbf6 100644 --- a/Assistant/DaemonStatus.hs +++ b/Assistant/DaemonStatus.hs @@ -181,8 +181,8 @@ adjustTransfersSTM dstatus a = do putTMVar dstatus $ s { currentTransfers = a (currentTransfers s) } {- Alters a transfer's info, if the transfer is in the map. -} -alterTransferInfo :: Transfer -> (TransferInfo -> TransferInfo) -> DaemonStatusHandle -> IO () -alterTransferInfo t a dstatus = updateTransferInfo' dstatus $ M.adjust a t +alterTransferInfo :: DaemonStatusHandle -> Transfer -> (TransferInfo -> TransferInfo) -> IO () +alterTransferInfo dstatus t a = updateTransferInfo' dstatus $ M.adjust a t {- Updates a transfer's info. Adds the transfer to the map if necessary, - or if already present, updates it while preserving the old transferTid, diff --git a/Assistant/Monad.hs b/Assistant/Monad.hs index ef9e7a4cb..a22b10446 100644 --- a/Assistant/Monad.hs +++ b/Assistant/Monad.hs @@ -13,6 +13,7 @@ module Assistant.Monad ( newAssistantData, runAssistant, getAssistant, + withAssistant, liftAnnex, (<~>), (<<~), @@ -111,5 +112,7 @@ asIO2 a = do (<<~) :: (a -> IO b) -> (AssistantData -> a) -> Assistant b io <<~ v = reader v >>= liftIO . io +withAssistant v io = io <<~ v + daemonStatus :: Assistant DaemonStatus daemonStatus = getDaemonStatus <<~ daemonStatusHandle diff --git a/Assistant/Threads/TransferPoller.hs b/Assistant/Threads/TransferPoller.hs index 6f54336bb..e28c24364 100644 --- a/Assistant/Threads/TransferPoller.hs +++ b/Assistant/Threads/TransferPoller.hs @@ -52,6 +52,7 @@ transferPollerThread = NamedThread "TransferPoller" $ do newsize t info sz | bytesComplete info /= sz && isJust sz = - alterTransferInfo t (\i -> i { bytesComplete = sz }) - <<~ daemonStatusHandle + withAssistant daemonStatusHandle $ \h -> + alterTransferInfo h t $ + \i -> i { bytesComplete = sz } | otherwise = noop diff --git a/Assistant/Threads/TransferWatcher.hs b/Assistant/Threads/TransferWatcher.hs index ad341b00a..a9925c9e5 100644 --- a/Assistant/Threads/TransferWatcher.hs +++ b/Assistant/Threads/TransferWatcher.hs @@ -79,9 +79,9 @@ onModify file = do Just t -> go t =<< liftIO (readTransferInfoFile Nothing file) where go _ Nothing = noop - go t (Just newinfo) = alterTransferInfo t - (\i -> i { bytesComplete = bytesComplete newinfo }) - <<~ daemonStatusHandle + go t (Just newinfo) = withAssistant daemonStatusHandle $ \h -> + alterTransferInfo h t $ + \i -> i { bytesComplete = bytesComplete newinfo } {- This thread can only watch transfer sizes when the DirWatcher supports - tracking modificatons to files. -} |