summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Assistant/DaemonStatus.hs4
-rw-r--r--Assistant/Monad.hs3
-rw-r--r--Assistant/Threads/TransferPoller.hs5
-rw-r--r--Assistant/Threads/TransferWatcher.hs6
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. -}