diff options
Diffstat (limited to 'Command/Copy.hs')
-rw-r--r-- | Command/Copy.hs | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/Command/Copy.hs b/Command/Copy.hs index e5b093c61..1b9b2aac8 100644 --- a/Command/Copy.hs +++ b/Command/Copy.hs @@ -15,26 +15,32 @@ import Annex.Wanted import Config.NumCopies cmd :: [Command] -cmd = [withOptions Command.Move.moveOptions $ command "copy" paramPaths seek +cmd = [withOptions copyOptions $ command "copy" paramPaths seek SectionCommon "copy content of files to/from another repository"] +copyOptions :: [Option] +copyOptions = Command.Move.moveOptions ++ [autoOption] + seek :: CommandSeek seek ps = do to <- getOptionField toOption Remote.byNameWithUUID from <- getOptionField fromOption Remote.byNameWithUUID - withKeyOptions + auto <- getOptionFlag autoOption + withKeyOptions auto (Command.Move.startKey to from False) - (withFilesInGit $ whenAnnexed $ start to from) + (withFilesInGit $ whenAnnexed $ start auto to from) ps {- A copy is just a move that does not delete the source file. - - However, --auto mode avoids unnecessary copies, and avoids getting or + - However, auto mode avoids unnecessary copies, and avoids getting or - sending non-preferred content. -} -start :: Maybe Remote -> Maybe Remote -> FilePath -> Key -> CommandStart -start to from file key = stopUnless shouldCopy $ +start :: Bool -> Maybe Remote -> Maybe Remote -> FilePath -> Key -> CommandStart +start auto to from file key = stopUnless shouldCopy $ Command.Move.start to from False file key where - shouldCopy = checkAuto (check <||> numCopiesCheck file key (<)) - check = case to of + shouldCopy + | auto = want <||> numCopiesCheck file key (<) + | otherwise = return True + want = case to of Nothing -> wantGet False (Just key) (Just file) Just r -> wantSend False (Just key) (Just file) (Remote.uuid r) |