plumb in LiveUpdate to copy/get/move/mirror
copy and get do check preferred content, so need to prepareLiveUpdate. move and mirror do not, but copy is implemented using move, so move also needed to have a LiveUpdate plumbed through.
This commit is contained in:
parent
418fbf3f2f
commit
eb841ab004
4 changed files with 110 additions and 90 deletions
|
@ -56,42 +56,44 @@ seek o = startConcurrency transferStages $ do
|
|||
ww = WarnUnmatchLsFiles "get"
|
||||
|
||||
start :: GetOptions -> Maybe Remote -> SeekInput -> RawFilePath -> Key -> CommandStart
|
||||
start o from si file key = start' expensivecheck from key afile ai si
|
||||
start o from si file key = do
|
||||
lu <- prepareLiveUpdate Nothing key AddingKey
|
||||
start' lu (expensivecheck lu) from key afile ai si
|
||||
where
|
||||
afile = AssociatedFile (Just file)
|
||||
ai = mkActionItem (key, afile)
|
||||
expensivecheck
|
||||
expensivecheck lu
|
||||
| autoMode o = numCopiesCheck file key (<)
|
||||
<||> wantGet False (Just key) afile
|
||||
<||> wantGet lu False (Just key) afile
|
||||
| otherwise = return True
|
||||
|
||||
startKeys :: Maybe Remote -> (SeekInput, Key, ActionItem) -> CommandStart
|
||||
startKeys from (si, key, ai) = checkFailedTransferDirection ai Download $
|
||||
start' (return True) from key (AssociatedFile Nothing) ai si
|
||||
start' NoLiveUpdate (return True) from key (AssociatedFile Nothing) ai si
|
||||
|
||||
start' :: Annex Bool -> Maybe Remote -> Key -> AssociatedFile -> ActionItem -> SeekInput -> CommandStart
|
||||
start' expensivecheck from key afile ai si =
|
||||
start' :: LiveUpdate -> Annex Bool -> Maybe Remote -> Key -> AssociatedFile -> ActionItem -> SeekInput -> CommandStart
|
||||
start' lu expensivecheck from key afile ai si =
|
||||
stopUnless expensivecheck $
|
||||
case from of
|
||||
Nothing -> go $ perform key afile
|
||||
Nothing -> go $ perform lu key afile
|
||||
Just src ->
|
||||
stopUnless (Command.Move.fromOk src key) $
|
||||
go $ Command.Move.fromPerform src Command.Move.RemoveNever key afile
|
||||
go $ Command.Move.fromPerform lu src Command.Move.RemoveNever key afile
|
||||
where
|
||||
go = starting "get" (OnlyActionOn key ai) si
|
||||
|
||||
perform :: Key -> AssociatedFile -> CommandPerform
|
||||
perform key afile = stopUnless (getKey key afile) $
|
||||
perform :: LiveUpdate -> Key -> AssociatedFile -> CommandPerform
|
||||
perform lu key afile = stopUnless (getKey lu key afile) $
|
||||
next $ return True -- no cleanup needed
|
||||
|
||||
{- Try to find a copy of the file in one of the remotes,
|
||||
- and copy it to here. -}
|
||||
getKey :: Key -> AssociatedFile -> Annex Bool
|
||||
getKey key afile = getKey' key afile
|
||||
getKey :: LiveUpdate -> Key -> AssociatedFile -> Annex Bool
|
||||
getKey lu key afile = getKey' lu key afile
|
||||
=<< Remote.keyPossibilities (Remote.IncludeIgnored False) key
|
||||
|
||||
getKey' :: Key -> AssociatedFile -> [Remote] -> Annex Bool
|
||||
getKey' key afile = dispatch
|
||||
getKey' :: LiveUpdate -> Key -> AssociatedFile -> [Remote] -> Annex Bool
|
||||
getKey' lu key afile = dispatch
|
||||
where
|
||||
dispatch [] = do
|
||||
showNote (UnquotedString "not available")
|
||||
|
@ -119,5 +121,5 @@ getKey' key afile = dispatch
|
|||
| otherwise = return True
|
||||
docopy r witness = do
|
||||
showAction $ UnquotedString $ "from " ++ Remote.name r
|
||||
logStatusAfter key $
|
||||
logStatusAfter lu key $
|
||||
download r key afile stdRetry witness
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue