summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar guilhem <guilhem@fripost.org>2013-03-29 01:34:07 +0100
committerGravatar Joey Hess <joey@kitenet.net>2013-03-30 18:49:43 -0400
commit27ab9830f16642b03ee97e7257d8973573a6d919 (patch)
tree9ff6abb1d871c73fee38d40d7a61c58a7ff1e109 /Command
parent53bec08da77705b1a50585e741854453322573a9 (diff)
Make git-annex-shell call the command with its (safe) options.
Diffstat (limited to 'Command')
-rw-r--r--Command/RecvKey.hs18
-rw-r--r--Command/SendKey.hs20
2 files changed, 25 insertions, 13 deletions
diff --git a/Command/RecvKey.hs b/Command/RecvKey.hs
index c5ff4a9c8..c1c11a550 100644
--- a/Command/RecvKey.hs
+++ b/Command/RecvKey.hs
@@ -11,6 +11,7 @@ import Common.Annex
import Command
import CmdLine
import Annex.Content
+import Annex
import Utility.Rsync
import Logs.Transfer
import Command.SendKey (fieldTransfer)
@@ -19,6 +20,8 @@ import qualified Types.Key
import qualified Types.Backend
import qualified Backend
+import System.Console.GetOpt
+
def :: [Command]
def = [noCommit $ command "recvkey" paramKey seek
SectionPlumbing "runs rsync in server mode to receive content"]
@@ -40,13 +43,16 @@ start key = ifM (inAnnex key)
)
)
where
- go tmp = ifM (liftIO $ rsyncServerReceive tmp)
- ( ifM (isJust <$> Fields.getField Fields.direct)
- ( directcheck tmp
- , return True
+ go tmp = do
+ (opts,_,_) <- getOpt Permute rsyncSafeOptions <$>
+ maybe [] (split " ") <$> getField "RsyncOptions"
+ ifM (liftIO $ rsyncServerReceive (map Param opts) tmp)
+ ( ifM (isJust <$> Fields.getField Fields.direct)
+ ( directcheck tmp
+ , return True
+ )
+ , return False
)
- , return False
- )
{- If the sending repository uses direct mode, the file
- it sends could be modified as it's sending it. So check
- that the right size file was received, and that the key/value
diff --git a/Command/SendKey.hs b/Command/SendKey.hs
index 0a07dcece..42a0377a3 100644
--- a/Command/SendKey.hs
+++ b/Command/SendKey.hs
@@ -10,11 +10,14 @@ module Command.SendKey where
import Common.Annex
import Command
import Annex.Content
+import Annex
import Utility.Rsync
import Logs.Transfer
import qualified Fields
import Utility.Metered
+import System.Console.GetOpt
+
def :: [Command]
def = [noCommit $ command "sendkey" paramKey seek
SectionPlumbing "runs rsync in server mode to send content"]
@@ -23,13 +26,16 @@ seek :: [CommandSeek]
seek = [withKeys start]
start :: Key -> CommandStart
-start key = ifM (inAnnex key)
- ( fieldTransfer Upload key $ \_p ->
- sendAnnex key rollback $ liftIO . rsyncServerSend
- , do
- warning "requested key is not present"
- liftIO exitFailure
- )
+start key = do
+ (opts,_,_) <- getOpt Permute rsyncSafeOptions <$>
+ maybe [] (split " ") <$> getField "RsyncOptions"
+ ifM (inAnnex key)
+ ( fieldTransfer Upload key $ \_p ->
+ sendAnnex key rollback $ liftIO . rsyncServerSend (map Param opts)
+ , do
+ warning "requested key is not present"
+ liftIO exitFailure
+ )
where
{- No need to do any rollback; when sendAnnex fails, a nonzero
- exit will be propigated, and the remote will know the transfer