summaryrefslogtreecommitdiff
path: root/Assistant
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-01-23 16:37:08 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-01-23 16:44:02 -0400
commit5112650348f6bf04cebe1fb97ed900b24e4aaac1 (patch)
tree4e207b96021812213d237e68d156e2e0bbdf32c3 /Assistant
parent425c6ddfcd84b6bf26f3a277d010df1fb6b018da (diff)
fix transfers of key with no associated file
Several places assumed this would not happen, and when the AssociatedFile was Nothing, did nothing. As part of this, preferred content checks pass the Key around. Note that checkMatcher is sometimes now called with Just Key and Just File. It currently constructs a FileMatcher, ignoring the Key. However, if it constructed a FileKeyMatcher, which contained both, then it might be possible to speed up parts of Limit, which currently call the somewhat expensive lookupFileKey to get the Key. I have not made this optimisation yet, because I am not sure if the key is always the same. Will need some significant checking to satisfy myself that's the case..
Diffstat (limited to 'Assistant')
-rw-r--r--Assistant/Drop.hs1
-rw-r--r--Assistant/Threads/TransferScanner.hs4
-rw-r--r--Assistant/TransferQueue.hs4
-rw-r--r--Assistant/TransferSlots.hs18
4 files changed, 14 insertions, 13 deletions
diff --git a/Assistant/Drop.hs b/Assistant/Drop.hs
index 3020b0f4f..faff37a23 100644
--- a/Assistant/Drop.hs
+++ b/Assistant/Drop.hs
@@ -19,7 +19,6 @@ import RunCommand
{- Drop from local and/or remote when allowed by the preferred content and
- numcopies settings. -}
handleDrops :: Reason -> Bool -> Key -> AssociatedFile -> Maybe Remote -> Assistant ()
-handleDrops _ _ _ Nothing _ = noop
handleDrops reason fromhere key f knownpresentremote = do
syncrs <- syncDataRemotes <$> getDaemonStatus
locs <- liftAnnex $ loggedLocations key
diff --git a/Assistant/Threads/TransferScanner.hs b/Assistant/Threads/TransferScanner.hs
index 60f6dc28b..6aefb2920 100644
--- a/Assistant/Threads/TransferScanner.hs
+++ b/Assistant/Threads/TransferScanner.hs
@@ -164,9 +164,9 @@ expensiveScan urlrenderer rs = unless onlyweb $ batch <~> do
let slocs = S.fromList locs
let use a = return $ mapMaybe (a key slocs) syncrs
ts <- if present
- then filterM (wantSend True (Just f) . Remote.uuid . fst)
+ then filterM (wantSend True (Just key) (Just f) . Remote.uuid . fst)
=<< use (genTransfer Upload False)
- else ifM (wantGet True $ Just f)
+ else ifM (wantGet True (Just key) (Just f))
( use (genTransfer Download True) , return [] )
let unwanted' = S.difference unwanted slocs
return (unwanted', ts)
diff --git a/Assistant/TransferQueue.hs b/Assistant/TransferQueue.hs
index 6d8e72852..86dd36d04 100644
--- a/Assistant/TransferQueue.hs
+++ b/Assistant/TransferQueue.hs
@@ -58,7 +58,7 @@ queueTransfers = queueTransfersMatching (const True)
- condition. Honors preferred content settings. -}
queueTransfersMatching :: (UUID -> Bool) -> Reason -> Schedule -> Key -> AssociatedFile -> Direction -> Assistant ()
queueTransfersMatching matching reason schedule k f direction
- | direction == Download = whenM (liftAnnex $ wantGet True f) go
+ | direction == Download = whenM (liftAnnex $ wantGet True (Just k) f) go
| otherwise = go
where
go = do
@@ -82,7 +82,7 @@ queueTransfersMatching matching reason schedule k f direction
- already have it. -}
| otherwise = do
s <- locs
- filterM (wantSend True f . Remote.uuid) $
+ filterM (wantSend True (Just k) f . Remote.uuid) $
filter (\r -> not (inset s r || Remote.readonly r)) rs
where
locs = S.fromList <$> Remote.keyLocations k
diff --git a/Assistant/TransferSlots.hs b/Assistant/TransferSlots.hs
index cb5d61a39..6fc8c3fd7 100644
--- a/Assistant/TransferSlots.hs
+++ b/Assistant/TransferSlots.hs
@@ -103,8 +103,8 @@ runTransferThread' program batchmaker d run = go
{- By the time this is called, the daemonstatus's currentTransfers map should
- already have been updated to include the transfer. -}
genTransfer :: Transfer -> TransferInfo -> TransferGenerator
-genTransfer t info = case (transferRemote info, associatedFile info) of
- (Just remote, Just file)
+genTransfer t info = case transferRemote info of
+ Just remote
| Git.repoIsLocalUnknown (Remote.repo remote) -> do
-- optimisation for removable drives not plugged in
liftAnnex $ recordFailedTransfer t info
@@ -114,7 +114,7 @@ genTransfer t info = case (transferRemote info, associatedFile info) of
( do
debug [ "Transferring:" , describeTransfer t info ]
notifyTransfer
- return $ Just (t, info, go remote file)
+ return $ Just (t, info, go remote)
, do
debug [ "Skipping unnecessary transfer:",
describeTransfer t info ]
@@ -149,10 +149,12 @@ genTransfer t info = case (transferRemote info, associatedFile info) of
- usual cleanup. However, first check if something else is
- running the transfer, to avoid removing active transfers.
-}
- go remote file transferrer = ifM (liftIO $ performTransfer transferrer t $ associatedFile info)
+ go remote transferrer = ifM (liftIO $ performTransfer transferrer t $ associatedFile info)
( do
- void $ addAlert $ makeAlertFiller True $
- transferFileAlert direction True file
+ maybe noop
+ (void . addAlert . makeAlertFiller True
+ . transferFileAlert direction True)
+ (associatedFile info)
unless isdownload $
handleDrops
("object uploaded to " ++ show remote)
@@ -188,11 +190,11 @@ genTransfer t info = case (transferRemote info, associatedFile info) of
shouldTransfer :: Transfer -> TransferInfo -> Annex Bool
shouldTransfer t info
| transferDirection t == Download =
- (not <$> inAnnex key) <&&> wantGet True file
+ (not <$> inAnnex key) <&&> wantGet True (Just key) file
| transferDirection t == Upload = case transferRemote info of
Nothing -> return False
Just r -> notinremote r
- <&&> wantSend True file (Remote.uuid r)
+ <&&> wantSend True (Just key) file (Remote.uuid r)
| otherwise = return False
where
key = transferKey t