summaryrefslogtreecommitdiff
path: root/Assistant/TransferQueue.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2017-09-20 13:27:59 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2017-09-20 13:58:27 -0400
commitd20933a25956a3a07247f66fe3a554761d616173 (patch)
tree47bd006b6255beac3b7286977988c64dce6236a2 /Assistant/TransferQueue.hs
parent7fa114e629fe33822763f376ac57b0efd48d5686 (diff)
first pass at assistant knowing about export remotes
Split exportRemotes out from syncDataRemotes; the parts of the assistant that upload keys and drop keys from remotes don't apply to exports, because those operations are not supported. Some parts of the assistant and webapp do operate on both syncDataRemotes and exportRemotes. Particularly when downloading from either of them. Added a downloadRemotes that combines both. With this, the assistant should download from exports, but it won't yet upload changes to them. This commit was sponsored by Fernando Jimenez on Patreon.
Diffstat (limited to 'Assistant/TransferQueue.hs')
-rw-r--r--Assistant/TransferQueue.hs13
1 files changed, 6 insertions, 7 deletions
diff --git a/Assistant/TransferQueue.hs b/Assistant/TransferQueue.hs
index 8117d309c..278bcbaa1 100644
--- a/Assistant/TransferQueue.hs
+++ b/Assistant/TransferQueue.hs
@@ -66,9 +66,7 @@ queueTransfersMatching matching reason schedule k f direction
| otherwise = go
where
go = do
-
- rs <- liftAnnex . selectremotes
- =<< syncDataRemotes <$> getDaemonStatus
+ rs <- liftAnnex . selectremotes =<< getDaemonStatus
let matchingrs = filter (matching . Remote.uuid) rs
if null matchingrs
then do
@@ -78,20 +76,21 @@ queueTransfersMatching matching reason schedule k f direction
forM_ matchingrs $ \r ->
enqueue reason schedule (gentransfer r) (stubInfo f r)
return True
- selectremotes rs
+ selectremotes st
{- Queue downloads from all remotes that
- have the key. The list of remotes is ordered with
- cheapest first. More expensive ones will only be tried
- if downloading from a cheap one fails. -}
| direction == Download = do
s <- locs
- return $ filter (inset s) rs
+ return $ filter (inset s) (downloadRemotes st)
{- Upload to all remotes that want the content and don't
- already have it. -}
| otherwise = do
s <- locs
filterM (wantSend True (Just k) f . Remote.uuid) $
- filter (\r -> not (inset s r || Remote.readonly r)) rs
+ filter (\r -> not (inset s r || Remote.readonly r))
+ (syncDataRemotes st)
where
locs = S.fromList <$> Remote.keyLocations k
inset s r = S.member (Remote.uuid r) s
@@ -114,7 +113,7 @@ queueDeferredDownloads :: Reason -> Schedule -> Assistant ()
queueDeferredDownloads reason schedule = do
q <- getAssistant transferQueue
l <- liftIO $ atomically $ readTList (deferreddownloads q)
- rs <- syncDataRemotes <$> getDaemonStatus
+ rs <- downloadRemotes <$> getDaemonStatus
left <- filterM (queue rs) l
unless (null left) $
liftIO $ atomically $ appendTList (deferreddownloads q) left