From f776ac0a11d03daabdcb7d5318588e7e669a7386 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 26 Dec 2015 13:59:27 -0400 Subject: [PATCH] add unlocked flag for git-annex-shell recvkey The direct flag is also set when sending unlocked content, to support old versions of git-annex-shell. At some point, the direct flag will be removed, and only the unlocked flag will be used. --- CmdLine/GitAnnexShell.hs | 1 + CmdLine/GitAnnexShell/Fields.hs | 3 +++ Command/RecvKey.hs | 7 ++++--- Remote/Helper/Ssh.hs | 7 +++++-- doc/git-annex-shell.mdwn | 2 +- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CmdLine/GitAnnexShell.hs b/CmdLine/GitAnnexShell.hs index f9678d1449..09108f8795 100644 --- a/CmdLine/GitAnnexShell.hs +++ b/CmdLine/GitAnnexShell.hs @@ -144,6 +144,7 @@ checkField :: (String, String) -> Bool checkField (field, val) | field == fieldName remoteUUID = fieldCheck remoteUUID val | field == fieldName associatedFile = fieldCheck associatedFile val + | field == fieldName unlocked = fieldCheck unlocked val | field == fieldName direct = fieldCheck direct val | field == fieldName autoInit = fieldCheck autoInit val | otherwise = False diff --git a/CmdLine/GitAnnexShell/Fields.hs b/CmdLine/GitAnnexShell/Fields.hs index bc26df73f7..1b76fc766f 100644 --- a/CmdLine/GitAnnexShell/Fields.hs +++ b/CmdLine/GitAnnexShell/Fields.hs @@ -35,5 +35,8 @@ associatedFile = Field "associatedfile" $ \f -> direct :: Field direct = Field "direct" $ \f -> f == "1" +unlocked :: Field +unlocked = Field "unlocked" $ \f -> f == "1" + autoInit :: Field autoInit = Field "autoinit" $ \f -> f == "1" diff --git a/Command/RecvKey.hs b/Command/RecvKey.hs index 988c4f90e1..51bf69b1f8 100644 --- a/Command/RecvKey.hs +++ b/Command/RecvKey.hs @@ -27,10 +27,11 @@ seek = withKeys start start :: Key -> CommandStart start key = fieldTransfer Download key $ \_p -> do - -- Always verify content when a direct mode repo is sending a file, + -- Always verify content when a repo is sending an unlocked file, -- as the file could change while being transferred. - fromdirect <- isJust <$> Fields.getField Fields.direct - let verify = if fromdirect then AlwaysVerify else DefaultVerify + fromunlocked <- (isJust <$> Fields.getField Fields.unlocked) + <||> (isJust <$> Fields.getField Fields.direct) + let verify = if fromunlocked then AlwaysVerify else DefaultVerify ifM (getViaTmp verify key go) ( do -- forcibly quit after receiving one key, diff --git a/Remote/Helper/Ssh.hs b/Remote/Helper/Ssh.hs index 0442ce8398..1545fa21db 100644 --- a/Remote/Helper/Ssh.hs +++ b/Remote/Helper/Ssh.hs @@ -126,10 +126,13 @@ rsyncHelper m params = do {- Generates rsync parameters that ssh to the remote and asks it - to either receive or send the key's content. -} rsyncParamsRemote :: Bool -> Remote -> Direction -> Key -> FilePath -> AssociatedFile -> Annex [CommandParam] -rsyncParamsRemote direct r direction key file afile = do +rsyncParamsRemote unlocked r direction key file afile = do u <- getUUID let fields = (Fields.remoteUUID, fromUUID u) - : (Fields.direct, if direct then "1" else "") + : (Fields.unlocked, if unlocked then "1" else "") + -- Send direct field for unlocked content, for backwards + -- compatability. + : (Fields.direct, if unlocked then "1" else "") : maybe [] (\f -> [(Fields.associatedFile, f)]) afile Just (shellcmd, shellparams) <- git_annex_shell (repo r) (if direction == Download then "sendkey" else "recvkey") diff --git a/doc/git-annex-shell.mdwn b/doc/git-annex-shell.mdwn index 73517ba895..3ac9926ed5 100644 --- a/doc/git-annex-shell.mdwn +++ b/doc/git-annex-shell.mdwn @@ -107,7 +107,7 @@ to git-annex-shell are: on new dashed options). Currently used fields include remoteuuid=, associatedfile=, - direct=, and autoinit= + unlocked=, direct=, and autoinit= # HOOK