rename key2file and file2key
What these generate is not really suitable to be used as a filename, which is why keyFile and fileKey further escape it. These are just serializing Keys. Also removed a quickcheck test that was very unlikely to test anything useful, since it relied on random chance creating something that looks like a serialized key. The other test is sufficient for testing what that was intended to test anyway.
This commit is contained in:
parent
ff0a2bee2d
commit
d3ab5e626b
40 changed files with 97 additions and 108 deletions
|
@ -186,7 +186,7 @@ checkKey' r serial aloc = do
|
|||
|
||||
androidLocation :: AndroidPath -> Key -> AndroidPath
|
||||
androidLocation adir k = AndroidPath $
|
||||
fromAndroidPath (androidHashDir adir k) ++ key2file k
|
||||
fromAndroidPath (androidHashDir adir k) ++ serializeKey k
|
||||
|
||||
androidHashDir :: AndroidPath -> Key -> AndroidPath
|
||||
androidHashDir adir k = AndroidPath $
|
||||
|
|
|
@ -280,7 +280,7 @@ bupRef k
|
|||
| Git.Ref.legal True shown = shown
|
||||
| otherwise = "git-annex-" ++ show (sha2_256 (fromString shown))
|
||||
where
|
||||
shown = key2file k
|
||||
shown = serializeKey k
|
||||
|
||||
bupLocal :: BupRepo -> Bool
|
||||
bupLocal = notElem ':'
|
||||
|
|
|
@ -110,7 +110,7 @@ store ddarrepo = fileStorer $ \k src _p -> do
|
|||
let params =
|
||||
[ Param "c"
|
||||
, Param "-N"
|
||||
, Param $ key2file k
|
||||
, Param $ serializeKey k
|
||||
, Param $ ddarRepoLocation ddarrepo
|
||||
, File src
|
||||
]
|
||||
|
@ -138,7 +138,7 @@ ddarRemoteCall cs ddarrepo cmd params
|
|||
{- Specialized ddarRemoteCall that includes extraction command and flags -}
|
||||
ddarExtractRemoteCall :: ConsumeStdin -> DdarRepo -> Key -> Annex (String, [CommandParam])
|
||||
ddarExtractRemoteCall cs ddarrepo k =
|
||||
ddarRemoteCall cs ddarrepo 'x' [Param "--force-stdout", Param $ key2file k]
|
||||
ddarRemoteCall cs ddarrepo 'x' [Param "--force-stdout", Param $ serializeKey k]
|
||||
|
||||
retrieve :: DdarRepo -> Retriever
|
||||
retrieve ddarrepo = byteRetriever $ \k sink -> do
|
||||
|
@ -154,7 +154,7 @@ retrieveCheap _ _ _ = return False
|
|||
remove :: DdarRepo -> Remover
|
||||
remove ddarrepo key = do
|
||||
(cmd, params) <- ddarRemoteCall NoConsumeStdin ddarrepo 'd'
|
||||
[Param $ key2file key]
|
||||
[Param $ serializeKey key]
|
||||
liftIO $ boolSystem cmd params
|
||||
|
||||
ddarDirectoryExists :: DdarRepo -> Annex (Either String Bool)
|
||||
|
@ -188,7 +188,7 @@ inDdarManifest ddarrepo k = do
|
|||
contents <- hGetContents h
|
||||
return $ elem k' $ lines contents
|
||||
where
|
||||
k' = key2file k
|
||||
k' = serializeKey k
|
||||
|
||||
checkKey :: DdarRepo -> CheckPresent
|
||||
checkKey ddarrepo key = do
|
||||
|
|
|
@ -427,7 +427,7 @@ lockKey' repo r (State connpool duc _) key callback
|
|||
fallback = do
|
||||
Just (cmd, params) <- Ssh.git_annex_shell ConsumeStdin
|
||||
repo "lockcontent"
|
||||
[Param $ key2file key] []
|
||||
[Param $ serializeKey key] []
|
||||
(Just hin, Just hout, Nothing, p) <- liftIO $
|
||||
withFile devNull WriteMode $ \nullh ->
|
||||
createProcess $
|
||||
|
@ -530,7 +530,7 @@ copyFromRemote'' repo forcersync r (State connpool _ _) key file dest meterupdat
|
|||
: maybe [] (\f -> [(Fields.associatedFile, f)]) afile
|
||||
Just (cmd, params) <- Ssh.git_annex_shell ConsumeStdin
|
||||
repo "transferinfo"
|
||||
[Param $ key2file key] fields
|
||||
[Param $ serializeKey key] fields
|
||||
v <- liftIO (newEmptySV :: IO (MSampleVar Integer))
|
||||
pidv <- liftIO $ newEmptyMVar
|
||||
tid <- liftIO $ forkIO $ void $ tryIO $ do
|
||||
|
|
|
@ -197,7 +197,7 @@ checkKey r k = do
|
|||
{- glacier checkpresent outputs the archive name to stdout if
|
||||
- it's present. -}
|
||||
s <- liftIO $ readProcessEnv "glacier" (toCommand params) (Just e)
|
||||
let probablypresent = key2file k `elem` lines s
|
||||
let probablypresent = serializeKey k `elem` lines s
|
||||
if probablypresent
|
||||
then ifM (Annex.getFlag "trustglacier")
|
||||
( return True, giveup untrusted )
|
||||
|
@ -253,7 +253,7 @@ getVault = fromMaybe (giveup "Missing vault configuration")
|
|||
. M.lookup "vault"
|
||||
|
||||
archive :: Remote -> Key -> Archive
|
||||
archive r k = fileprefix ++ key2file k
|
||||
archive r k = fileprefix ++ serializeKey k
|
||||
where
|
||||
fileprefix = M.findWithDefault "" "fileprefix" $ config r
|
||||
|
||||
|
@ -306,7 +306,7 @@ jobList r keys = go =<< glacierEnv (config r) (gitconfig r) (uuid r)
|
|||
parse c [] = c
|
||||
parse c@(succeeded, failed) ((status:_date:vault:key:[]):rest)
|
||||
| vault == myvault =
|
||||
case file2key key of
|
||||
case deserializeKey key of
|
||||
Nothing -> parse c rest
|
||||
Just k
|
||||
| "a/d" `isPrefixOf` status ->
|
||||
|
|
|
@ -98,7 +98,7 @@ onRemote cs r (with, errorval) command params fields = do
|
|||
inAnnex :: Git.Repo -> Key -> Annex Bool
|
||||
inAnnex r k = do
|
||||
showChecking r
|
||||
onRemote NoConsumeStdin r (runcheck, cantCheck r) "inannex" [Param $ key2file k] []
|
||||
onRemote NoConsumeStdin r (runcheck, cantCheck r) "inannex" [Param $ serializeKey k] []
|
||||
where
|
||||
runcheck c p = dispatch =<< safeSystem c p
|
||||
dispatch ExitSuccess = return True
|
||||
|
@ -109,7 +109,7 @@ inAnnex r k = do
|
|||
dropKey :: Git.Repo -> Key -> Annex Bool
|
||||
dropKey r key = onRemote NoConsumeStdin r (boolSystem, return False) "dropkey"
|
||||
[ Param "--quiet", Param "--force"
|
||||
, Param $ key2file key
|
||||
, Param $ serializeKey key
|
||||
]
|
||||
[]
|
||||
|
||||
|
@ -141,7 +141,7 @@ rsyncParamsRemote unlocked r direction key file (AssociatedFile afile) = do
|
|||
repo <- getRepo r
|
||||
Just (shellcmd, shellparams) <- git_annex_shell ConsumeStdin repo
|
||||
(if direction == Download then "sendkey" else "recvkey")
|
||||
[ Param $ key2file key ]
|
||||
[ Param $ serializeKey key ]
|
||||
fields
|
||||
-- Convert the ssh command into rsync command line.
|
||||
let eparam = rsyncShell (Param shellcmd:shellparams)
|
||||
|
|
|
@ -92,7 +92,7 @@ hookEnv action k f = Just <$> mergeenv (fileenv f ++ keyenv)
|
|||
mergeenv l = addEntries l <$> getEnvironment
|
||||
envvar s v = ("ANNEX_" ++ s, v)
|
||||
keyenv = catMaybes
|
||||
[ Just $ envvar "KEY" (key2file k)
|
||||
[ Just $ envvar "KEY" (serializeKey k)
|
||||
, Just $ envvar "ACTION" action
|
||||
, envvar "HASH_1" <$> headMaybe hashbits
|
||||
, envvar "HASH_2" <$> headMaybe (drop 1 hashbits)
|
||||
|
@ -151,7 +151,7 @@ checkKey r h k = do
|
|||
liftIO $ check v
|
||||
where
|
||||
action = "checkpresent"
|
||||
findkey s = key2file k `elem` lines s
|
||||
findkey s = serializeKey k `elem` lines s
|
||||
check Nothing = giveup $ action ++ " hook misconfigured"
|
||||
check (Just hook) = do
|
||||
environ <- hookEnv action k Nothing
|
||||
|
|
|
@ -653,7 +653,7 @@ getFilePrefix :: RemoteConfig -> String
|
|||
getFilePrefix = M.findWithDefault "" "fileprefix"
|
||||
|
||||
getBucketObject :: RemoteConfig -> Key -> BucketObject
|
||||
getBucketObject c = munge . key2file
|
||||
getBucketObject c = munge . serializeKey
|
||||
where
|
||||
munge s = case M.lookup "mungekeys" c of
|
||||
Just "ia" -> iaMunge $ getFilePrefix c ++ s
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue