summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-03-10 15:37:38 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-03-10 15:37:38 -0400
commit997e29f29491868f7d83235cdc2d312263509167 (patch)
treeb1df5d10e74e3fe9b7688c2a066b04b0caafe8ae
parent5ab82230f7668897a62f40fa100e51bb53d0c38e (diff)
sync: Sync to lower cost remotes first.
This has two benefits. 1. When a lot of refs are going to be received, get them via lower cost connection when possible. 2. Allows ctrl-c of sync after the cheaper remotes have been pulled from (or pushed to).
-rw-r--r--Command/Sync.hs6
-rw-r--r--debian/changelog1
2 files changed, 4 insertions, 3 deletions
diff --git a/Command/Sync.hs b/Command/Sync.hs
index f7ebba6f5..51b6d6f63 100644
--- a/Command/Sync.hs
+++ b/Command/Sync.hs
@@ -59,14 +59,14 @@ syncRemotes rs = do
where
pickfast = (++) <$> listed <*> (good =<< fastest <$> available)
wanted
- | null rs = good =<< available
+ | null rs = good =<< concat . byspeed <$> available
| otherwise = listed
listed = catMaybes <$> mapM (Remote.byName . Just) rs
available = filter nonspecial <$> Remote.enabledRemoteList
good = filterM $ Remote.Git.repoAvail . Types.Remote.repo
nonspecial r = Types.Remote.remotetype r == Remote.Git.remote
- fastest = fromMaybe [] . headMaybe .
- map snd . sort . M.toList . costmap
+ fastest = fromMaybe [] . headMaybe . byspeed
+ byspeed = map snd . sort . M.toList . costmap
costmap = M.fromListWith (++) . map costpair
costpair r = (Types.Remote.cost r, [r])
diff --git a/debian/changelog b/debian/changelog
index 1955f8b3b..10dc1c50c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,7 @@ git-annex (3.20120310) UNRELEASED; urgency=low
* fsck: Fix up any broken links and misplaced content caused by the
directory hash calculation bug fixed in the last release.
+ * sync: Sync to lower cost remotes first.
-- Joey Hess <joeyh@debian.org> Sat, 10 Mar 2012 14:03:22 -0400