diff options
author | Joey Hess <joey@kitenet.net> | 2012-07-17 12:17:01 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-07-17 12:17:01 -0400 |
commit | c34d8ae088e284b7585b7e32330945d1e9c922f2 (patch) | |
tree | 61a9049b1cccbeb2854896d3f2ca3c4ba0e9ce36 /Assistant/TransferQueue.hs | |
parent | b7d3cefde9a82a7a5bab90eb621690fc969da5ea (diff) |
avoid enqueing downloads from remotes that don't have the key
Diffstat (limited to 'Assistant/TransferQueue.hs')
-rw-r--r-- | Assistant/TransferQueue.hs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/Assistant/TransferQueue.hs b/Assistant/TransferQueue.hs index 5e1fad456..73e73ca0a 100644 --- a/Assistant/TransferQueue.hs +++ b/Assistant/TransferQueue.hs @@ -33,24 +33,24 @@ stubInfo f = TransferInfo {- Adds pending transfers to the end of the queue for some of the known - remotes. -} queueTransfers :: TransferQueue -> DaemonStatusHandle -> Key -> AssociatedFile -> Direction -> Annex () -queueTransfers q daemonstatus k f direction = +queueTransfers q daemonstatus k f direction = do + rs <- knownRemotes <$> getDaemonStatus daemonstatus mapM_ (\r -> queue r $ gentransfer r) - =<< sufficientremotes . knownRemotes - <$> getDaemonStatus daemonstatus + =<< sufficientremotes rs where sufficientremotes l - -- Queue downloads from all remotes, with the - -- cheapest ones first. More expensive ones will - -- only be tried if downloading from a cheap one - -- fails. - -- TODO: avoid downloading from remotes that don't - -- have the key. - | direction == Download = l + -- Queue downloads from all remotes that + -- have the key, with the cheapest ones first. + -- More expensive ones will only be tried if + -- downloading from a cheap one fails. + | direction == Download = do + uuids <- Remote.keyLocations k + return $ filter (\r -> uuid r `elem` uuids) l -- TODO: Determine a smaller set of remotes that -- can be uploaded to, in order to ensure all -- remotes can access the content. Currently, -- send to every remote we can. - | otherwise = l + | otherwise = return l gentransfer r = Transfer { transferDirection = direction , transferKey = k |