aboutsummaryrefslogtreecommitdiff
path: root/Command/Get.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-09-06 12:42:50 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-09-06 12:45:21 -0400
commitd90783a507ef2776cb43e0d55204adb7e91cfea5 (patch)
tree6e059450d0612966e5434db0d8709968618a4d6d /Command/Get.hs
parent14c485bb43f071e8f7ff2614bf3eb3e7a7ab0065 (diff)
get -J: Download different files from different remotes when the remotes have the same costs.
Only done in -J mode because only if there's concurrency can downloading from two remotes be faster. Without concurrency, it's likely the case that sequential downloads from the same remote are faster than switching back and forth between two remotes. There is some hairy MVar code here, but basically it just keeps the activeremotes MVar full except when deciding which remote to assign to a thread. Also affects gets by sync --content -J This commit was sponsored by Jochen Bartl.
Diffstat (limited to 'Command/Get.hs')
-rw-r--r--Command/Get.hs19
1 files changed, 10 insertions, 9 deletions
diff --git a/Command/Get.hs b/Command/Get.hs
index 3d2914673..70b877065 100644
--- a/Command/Get.hs
+++ b/Command/Get.hs
@@ -89,16 +89,17 @@ getKey' key afile = dispatch
showNote "not available"
showlocs
return False
- dispatch remotes = notifyTransfer Download afile $ trycopy remotes remotes
- trycopy full [] _ = do
- Remote.showTriedRemotes full
- showlocs
- return False
- trycopy full (r:rs) witness =
- ifM (probablyPresent r)
- ( docopy r witness <||> trycopy full rs witness
- , trycopy full rs witness
+ dispatch remotes = notifyTransfer Download afile $ \witness -> do
+ ok <- pickRemote remotes $ \r -> ifM (probablyPresent r)
+ ( docopy r witness
+ , return False
)
+ if ok
+ then return ok
+ else do
+ Remote.showTriedRemotes remotes
+ showlocs
+ return False
showlocs = Remote.showLocations False key []
"No other repository is known to contain the file."
-- This check is to avoid an ugly message if a remote is a