diff options
author | Joey Hess <joey@kitenet.net> | 2012-10-30 17:14:26 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-10-30 17:14:51 -0400 |
commit | 4318f594d544320825093de8661ed1b40e4774d5 (patch) | |
tree | 709dcd2fe739c503651bc7bd5e1df35a52a27977 /Assistant/Threads/TransferScanner.hs | |
parent | 07cd1b2b40735d460c8225762fcf3992b9886c60 (diff) |
finished pushing Assistant monad into all relevant files
All temporary and old functions are removed.
Diffstat (limited to 'Assistant/Threads/TransferScanner.hs')
-rw-r--r-- | Assistant/Threads/TransferScanner.hs | 42 |
1 files changed, 18 insertions, 24 deletions
diff --git a/Assistant/Threads/TransferScanner.hs b/Assistant/Threads/TransferScanner.hs index c37b1e3b9..3b3c3f304 100644 --- a/Assistant/Threads/TransferScanner.hs +++ b/Assistant/Threads/TransferScanner.hs @@ -21,7 +21,7 @@ import qualified Remote import qualified Types.Remote as Remote import Utility.ThreadScheduler import qualified Git.LsFiles as LsFiles -import Command +import qualified Backend import Annex.Content import Annex.Wanted @@ -78,11 +78,7 @@ failedTransferScan r = do - that the remote doesn't already have the - key, so it's not redundantly checked here. -} requeue t info - requeue t info = do - transferqueue <- getAssistant transferQueue - dstatus <- getAssistant daemonStatusHandle - liftIO $ queueTransferWhenSmall - transferqueue dstatus (associatedFile info) t r + requeue t info = queueTransferWhenSmall (associatedFile info) t r {- This is a expensive scan through the full git work tree, finding - files to transfer. The scan is blocked when the transfer queue gets @@ -101,10 +97,9 @@ expensiveScan rs = unless onlyweb $ do void $ alertWhile (scanAlert visiblers) $ do g <- liftAnnex gitRepo (files, cleanup) <- liftIO $ LsFiles.inRepo [] g - dstatus <- getAssistant daemonStatusHandle forM_ files $ \f -> do - ts <- liftAnnex $ - ifAnnexed f (findtransfers dstatus f) (return []) + ts <- maybe (return []) (findtransfers f) + =<< liftAnnex (Backend.lookupFile f) mapM_ (enqueue f) ts void $ liftIO cleanup return True @@ -115,25 +110,24 @@ expensiveScan rs = unless onlyweb $ do in if null rs' then rs else rs' enqueue f (r, t) = do debug ["queuing", show t] - transferqueue <- getAssistant transferQueue - dstatus <- getAssistant daemonStatusHandle - liftIO $ queueTransferWhenSmall transferqueue dstatus (Just f) t r - findtransfers dstatus f (key, _) = do - locs <- loggedLocations key + queueTransferWhenSmall (Just f) t r + findtransfers f (key, _) = do {- The syncable remotes may have changed since this - scan began. -} - syncrs <- liftIO $ syncRemotes <$> getDaemonStatusOld dstatus - present <- inAnnex key + syncrs <- syncRemotes <$> getDaemonStatus + liftAnnex $ do + locs <- loggedLocations key + present <- inAnnex key - handleDrops' locs syncrs present key (Just f) + handleDrops' locs syncrs present key (Just f) - let slocs = S.fromList locs - let use a = return $ catMaybes $ map (a key slocs) syncrs - if present - then filterM (wantSend (Just f) . Remote.uuid . fst) - =<< use (genTransfer Upload False) - else ifM (wantGet $ Just f) - ( use (genTransfer Download True) , return [] ) + let slocs = S.fromList locs + let use a = return $ catMaybes $ map (a key slocs) syncrs + if present + then filterM (wantSend (Just f) . Remote.uuid . fst) + =<< use (genTransfer Upload False) + else ifM (wantGet $ Just f) + ( use (genTransfer Download True) , return [] ) genTransfer :: Direction -> Bool -> Key -> S.Set UUID -> Remote -> Maybe (Remote, Transfer) genTransfer direction want key slocs r |