From c8135ea0a8aa2b374e45a8bb8c447c5287862838 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 5 Jul 2012 10:44:03 -0600 Subject: [PATCH] split logic for uploads and downloads --- Assistant/TransferQueue.hs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Assistant/TransferQueue.hs b/Assistant/TransferQueue.hs index fc25b057d3..f1f4882bef 100644 --- a/Assistant/TransferQueue.hs +++ b/Assistant/TransferQueue.hs @@ -30,13 +30,26 @@ stubInfo f = TransferInfo } {- Adds pending transfers to the end of the queue for some of the known - - remotes. (TBD: a smaller set of remotes that are sufficient to transfer to, - - rather than transferring to all.) -} + - remotes. -} queueTransfers :: TransferQueue -> DaemonStatusHandle -> Key -> AssociatedFile -> Direction -> Annex () queueTransfers q daemonstatus k f direction = mapM_ (liftIO . queueTransfer q f . gentransfer) - =<< knownRemotes <$> getDaemonStatus daemonstatus + =<< sufficientremotes . knownRemotes + <$> getDaemonStatus daemonstatus 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 + -- 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 gentransfer r = Transfer { transferDirection = direction , transferKey = k