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..
This commit is contained in:
parent
90bc6e3137
commit
3518c586cf
13 changed files with 79 additions and 64 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue