avoid queueing uploads to remotes that already have the content

This commit is contained in:
Joey Hess 2013-04-02 15:51:58 -04:00
parent db3e32e768
commit 0f6a6f2a8b
2 changed files with 17 additions and 8 deletions

View file

@ -32,6 +32,7 @@ import Annex.Wanted
import Control.Concurrent.STM import Control.Concurrent.STM
import qualified Data.Map as M import qualified Data.Map as M
import qualified Data.Set as S
type Reason = String type Reason = String
@ -58,6 +59,7 @@ queueTransfersMatching matching reason schedule k f direction
| otherwise = go | otherwise = go
where where
go = do go = do
rs <- liftAnnex . selectremotes rs <- liftAnnex . selectremotes
=<< syncDataRemotes <$> getDaemonStatus =<< syncDataRemotes <$> getDaemonStatus
let matchingrs = filter (matching . Remote.uuid) rs let matchingrs = filter (matching . Remote.uuid) rs
@ -67,15 +69,21 @@ queueTransfersMatching matching reason schedule k f direction
enqueue reason schedule (gentransfer r) (stubInfo f r) enqueue reason schedule (gentransfer r) (stubInfo f r)
selectremotes rs selectremotes rs
{- Queue downloads from all remotes that {- Queue downloads from all remotes that
- have the key, with the cheapest ones first. - have the key. The list of remotes is ordered with
- More expensive ones will only be tried if - cheapest first. More expensive ones will only be tried
- downloading from a cheap one fails. -} - if downloading from a cheap one fails. -}
| direction == Download = do | direction == Download = do
uuids <- Remote.keyLocations k s <- locs
return $ filter (\r -> uuid r `elem` uuids) rs return $ filter (inset s) rs
{- Upload to all remotes that want the content. -} {- Upload to all remotes that want the content and don't
| otherwise = filterM (wantSend True f . Remote.uuid) $ - already have it. -}
filter (not . Remote.readonly) rs | otherwise = do
s <- locs
filterM (wantSend True f . Remote.uuid) $
filter (\r -> not (inset s r || Remote.readonly r)) rs
where
locs = S.fromList <$> Remote.keyLocations k
inset s r = S.member (Remote.uuid r) s
gentransfer r = Transfer gentransfer r = Transfer
{ transferDirection = direction { transferDirection = direction
, transferKey = k , transferKey = k

1
debian/changelog vendored
View file

@ -27,6 +27,7 @@ git-annex (4.20130324) UNRELEASED; urgency=low
* assistant: Fix bug that could cause direct mode files to be unstaged * assistant: Fix bug that could cause direct mode files to be unstaged
from git. from git.
* Update working tree files fully atomically. * Update working tree files fully atomically.
* webapp: Improved transfer queue management.
-- Joey Hess <joeyh@debian.org> Mon, 25 Mar 2013 10:21:46 -0400 -- Joey Hess <joeyh@debian.org> Mon, 25 Mar 2013 10:21:46 -0400