aboutsummaryrefslogtreecommitdiff
path: root/Command/Copy.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-10-08 16:06:56 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-10-08 16:06:56 -0400
commit84a60358dfca930409622732aa023e6e00322319 (patch)
treefc9e8d53a5180ee67bb01ac6872b445f8cd55357 /Command/Copy.hs
parent98612f75ffee93be2973fd444948314dd1b7f822 (diff)
make copy --to check preferred content of the remote
Diffstat (limited to 'Command/Copy.hs')
-rw-r--r--Command/Copy.hs13
1 files changed, 10 insertions, 3 deletions
diff --git a/Command/Copy.hs b/Command/Copy.hs
index 5d92eef2e..c8a2d7efc 100644
--- a/Command/Copy.hs
+++ b/Command/Copy.hs
@@ -11,6 +11,7 @@ import Common.Annex
import Command
import qualified Command.Move
import qualified Remote
+import Annex.Wanted
def :: [Command]
def = [withOptions Command.Move.options $ command "copy" paramPaths seek
@@ -21,8 +22,14 @@ seek = [withField Command.Move.toOption Remote.byName $ \to ->
withField Command.Move.fromOption Remote.byName $ \from ->
withFilesInGit $ whenAnnexed $ start to from]
--- A copy is just a move that does not delete the source file.
--- However, --auto mode avoids unnecessary copies.
+{- A copy is just a move that does not delete the source file.
+ - However, --auto mode avoids unnecessary copies, and avoids getting or
+ - sending non-preferred content. -}
start :: Maybe Remote -> Maybe Remote -> FilePath -> (Key, Backend) -> CommandStart
start to from file (key, backend) = autoCopies file key (<) $
- Command.Move.start to from False file (key, backend)
+ stopUnless shouldCopy $
+ Command.Move.start to from False file (key, backend)
+ where
+ shouldCopy = case to of
+ Nothing -> checkAuto $ shouldGet file key
+ Just r -> checkAuto $ shouldSend r file