get, move, copy, mirror: Added --failed switch which retries failed copies/moves

Note that get --from foo --failed will get things that a previous get --from bar
tried and failed to get, etc. I considered making --failed only retry
transfers from the same remote, but it was easier, and seems more useful,
to not have the same remote requirement.

Noisy due to some refactoring into Types/
This commit is contained in:
Joey Hess 2016-08-03 12:37:12 -04:00
parent 0fc85c45b5
commit 1a0e2c9901
Failed to extract signature
53 changed files with 254 additions and 127 deletions

View file

@ -41,7 +41,7 @@ optParser desc = DropOptions
<$> cmdParams desc
<*> optional parseDropFromOption
<*> parseAutoOption
<*> optional (parseKeyOptions False)
<*> optional parseKeyOptions
<*> parseBatchOption
parseDropFromOption :: Parser (DeferredParse Remote)

View file

@ -66,7 +66,7 @@ optParser desc = FsckOptions
<> completeRemotes
))
<*> optional parseincremental
<*> optional (parseKeyOptions False)
<*> optional parseKeyOptions
where
parseincremental =
flag' StartIncrementalO

View file

@ -14,6 +14,7 @@ import Annex.Transfer
import Annex.NumCopies
import Annex.Wanted
import qualified Command.Move
import Types.ActionItem
cmd :: Command
cmd = withGlobalOptions (jobsOption : jsonOption : annexedMatchingOptions) $
@ -34,7 +35,7 @@ optParser desc = GetOptions
<$> cmdParams desc
<*> optional parseFromOption
<*> parseAutoOption
<*> optional (parseKeyOptions True)
<*> optional (parseIncompleteOption <|> parseKeyOptions <|> parseFailedTransfersOption)
<*> parseBatchOption
seek :: GetOptions -> CommandSeek
@ -57,7 +58,8 @@ start o from file key = start' expensivecheck from key afile (mkActionItem afile
| otherwise = return True
startKeys :: Maybe Remote -> Key -> ActionItem -> CommandStart
startKeys from key = start' (return True) from key Nothing
startKeys from key ai = checkFailedTransferDirection ai Download $
start' (return True) from key Nothing ai
start' :: Annex Bool -> Maybe Remote -> Key -> AssociatedFile -> ActionItem -> CommandStart
start' expensivecheck from key afile ai = stopUnless (not <$> inAnnex key) $

View file

@ -32,6 +32,7 @@ import Remote
import Config
import Git.Config (boolConfig)
import Utility.Percentage
import Types.Transfer
import Logs.Transfer
import Types.TrustLevel
import Types.FileMatcher

View file

@ -40,7 +40,7 @@ optParser :: CmdParamsDesc -> Parser MetaDataOptions
optParser desc = MetaDataOptions
<$> cmdParams desc
<*> ((Get <$> getopt) <|> (Set <$> some modopts) <|> pure GetAll)
<*> optional (parseKeyOptions False)
<*> optional parseKeyOptions
<*> parseBatchOption
where
getopt = option (eitherReader mkMetaField)

View file

@ -14,6 +14,7 @@ import qualified Command.Get
import qualified Remote
import Annex.Content
import Annex.NumCopies
import Types.Transfer
cmd :: Command
cmd = withGlobalOptions ([jobsOption] ++ annexedMatchingOptions) $
@ -31,7 +32,7 @@ optParser :: CmdParamsDesc -> Parser MirrorOptions
optParser desc = MirrorOptions
<$> cmdParams desc
<*> parseFromToOptions
<*> optional (parseKeyOptions False)
<*> optional (parseKeyOptions <|> parseFailedTransfersOption)
instance DeferredParseClass MirrorOptions where
finishParse v = MirrorOptions
@ -53,13 +54,13 @@ start o file k = startKey o afile k (mkActionItem afile)
startKey :: MirrorOptions -> Maybe FilePath -> Key -> ActionItem -> CommandStart
startKey o afile key ai = case fromToOptions o of
ToRemote r -> ifM (inAnnex key)
ToRemote r -> checkFailedTransferDirection ai Upload $ ifM (inAnnex key)
( Command.Move.toStart False afile key ai =<< getParsed r
, do
numcopies <- getnumcopies
Command.Drop.startRemote afile ai numcopies key =<< getParsed r
)
FromRemote r -> do
FromRemote r -> checkFailedTransferDirection ai Download $ do
haskey <- flip Remote.hasKey key =<< getParsed r
case haskey of
Left _ -> stop

View file

@ -35,7 +35,7 @@ optParser :: CmdParamsDesc -> Parser MoveOptions
optParser desc = MoveOptions
<$> cmdParams desc
<*> parseFromToOptions
<*> optional (parseKeyOptions False)
<*> optional (parseKeyOptions <|> parseFailedTransfersOption)
instance DeferredParseClass MoveOptions where
finishParse v = MoveOptions
@ -61,8 +61,10 @@ startKey o move = start' o move Nothing
start' :: MoveOptions -> Bool -> AssociatedFile -> Key -> ActionItem -> CommandStart
start' o move afile key ai =
case fromToOptions o of
FromRemote src -> fromStart move afile key ai =<< getParsed src
ToRemote dest -> toStart move afile key ai =<< getParsed dest
FromRemote src -> checkFailedTransferDirection ai Download $
fromStart move afile key ai =<< getParsed src
ToRemote dest -> checkFailedTransferDirection ai Upload $
toStart move afile key ai =<< getParsed dest
showMoveAction :: Bool -> Key -> ActionItem -> Annex ()
showMoveAction move = showStart' (if move then "move" else "copy")

View file

@ -12,7 +12,7 @@ import Annex.Content
import Annex.Action
import Annex
import Utility.Rsync
import Logs.Transfer
import Types.Transfer
import Command.SendKey (fieldTransfer)
import qualified CmdLine.GitAnnexShell.Fields as Fields

View file

@ -9,6 +9,7 @@ module Command.TransferInfo where
import Command
import Annex.Content
import Types.Transfer
import Logs.Transfer
import qualified CmdLine.GitAnnexShell.Fields as Fields
import Utility.Metered

View file

@ -31,7 +31,7 @@ data WhereisOptions = WhereisOptions
optParser :: CmdParamsDesc -> Parser WhereisOptions
optParser desc = WhereisOptions
<$> cmdParams desc
<*> optional (parseKeyOptions False)
<*> optional parseKeyOptions
<*> parseBatchOption
seek :: WhereisOptions -> CommandSeek