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.
This commit is contained in:
Joey Hess 2015-12-26 13:59:27 -04:00
parent f324ad24c1
commit f776ac0a11
Failed to extract signature
5 changed files with 14 additions and 6 deletions

View file

@ -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

View file

@ -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"

View file

@ -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,

View file

@ -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")

View file

@ -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