diff options
author | Joey Hess <joey@kitenet.net> | 2014-01-23 16:51:16 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-01-23 16:51:16 -0400 |
commit | 8d1787a73ddfb189005d80998503fae06b49c0f1 (patch) | |
tree | 15218a6dc0d15f4acca9e489301a055fe6c9ed8b /Assistant/TransferQueue.hs | |
parent | 5112650348f6bf04cebe1fb97ed900b24e4aaac1 (diff) |
try to drop unused object if it does not need to be transferred anywhere
Diffstat (limited to 'Assistant/TransferQueue.hs')
-rw-r--r-- | Assistant/TransferQueue.hs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/Assistant/TransferQueue.hs b/Assistant/TransferQueue.hs index 86dd36d04..93c982224 100644 --- a/Assistant/TransferQueue.hs +++ b/Assistant/TransferQueue.hs @@ -51,14 +51,17 @@ stubInfo f r = stubTransferInfo {- Adds transfers to queue for some of the known remotes. - Honors preferred content settings, only transferring wanted files. -} -queueTransfers :: Reason -> Schedule -> Key -> AssociatedFile -> Direction -> Assistant () +queueTransfers :: Reason -> Schedule -> Key -> AssociatedFile -> Direction -> Assistant Bool queueTransfers = queueTransfersMatching (const True) {- Adds transfers to queue for some of the known remotes, that match a - condition. Honors preferred content settings. -} -queueTransfersMatching :: (UUID -> Bool) -> Reason -> Schedule -> Key -> AssociatedFile -> Direction -> Assistant () +queueTransfersMatching :: (UUID -> Bool) -> Reason -> Schedule -> Key -> AssociatedFile -> Direction -> Assistant Bool queueTransfersMatching matching reason schedule k f direction - | direction == Download = whenM (liftAnnex $ wantGet True (Just k) f) go + | direction == Download = ifM (liftAnnex $ wantGet True (Just k) f) + ( go + , return False + ) | otherwise = go where go = do @@ -67,9 +70,13 @@ queueTransfersMatching matching reason schedule k f direction =<< syncDataRemotes <$> getDaemonStatus let matchingrs = filter (matching . Remote.uuid) rs if null matchingrs - then defer - else forM_ matchingrs $ \r -> - enqueue reason schedule (gentransfer r) (stubInfo f r) + then do + defer + return False + else do + forM_ matchingrs $ \r -> + enqueue reason schedule (gentransfer r) (stubInfo f r) + return True selectremotes rs {- Queue downloads from all remotes that - have the key. The list of remotes is ordered with |