rest of the deserializeKey renameing
This commit is contained in:
parent
1791447cc8
commit
303e828b7c
15 changed files with 19 additions and 19 deletions
|
@ -210,7 +210,7 @@ parseAllOption = flag' WantAllKeys
|
||||||
)
|
)
|
||||||
|
|
||||||
parseKey :: Monad m => String -> m Key
|
parseKey :: Monad m => String -> m Key
|
||||||
parseKey = maybe (fail "invalid key") return . file2key
|
parseKey = maybe (fail "invalid key") return . deserializeKey
|
||||||
|
|
||||||
-- Options to match properties of annexed files.
|
-- Options to match properties of annexed files.
|
||||||
annexedMatchingOptions :: [GlobalOption]
|
annexedMatchingOptions :: [GlobalOption]
|
||||||
|
|
|
@ -158,7 +158,7 @@ withFilesMaybeModified a params = seekActions $
|
||||||
withKeys :: (Key -> CommandSeek) -> CmdParams -> CommandSeek
|
withKeys :: (Key -> CommandSeek) -> CmdParams -> CommandSeek
|
||||||
withKeys a l = seekActions $ return $ map (a . parse) l
|
withKeys a l = seekActions $ return $ map (a . parse) l
|
||||||
where
|
where
|
||||||
parse p = fromMaybe (giveup "bad key") $ file2key p
|
parse p = fromMaybe (giveup "bad key") $ deserializeKey p
|
||||||
|
|
||||||
withNothing :: CommandSeek -> CmdParams -> CommandSeek
|
withNothing :: CommandSeek -> CmdParams -> CommandSeek
|
||||||
withNothing a [] = a
|
withNothing a [] = a
|
||||||
|
|
|
@ -69,7 +69,7 @@ batchResult Present = liftIO $ putStrLn "1"
|
||||||
batchResult _ = liftIO $ putStrLn "0"
|
batchResult _ = liftIO $ putStrLn "0"
|
||||||
|
|
||||||
toKey :: String -> Key
|
toKey :: String -> Key
|
||||||
toKey = fromMaybe (giveup "Bad key") . file2key
|
toKey = fromMaybe (giveup "Bad key") . deserializeKey
|
||||||
|
|
||||||
toRemote :: String -> Annex Remote
|
toRemote :: String -> Annex Remote
|
||||||
toRemote rn = maybe (giveup "Unknown remote") return
|
toRemote rn = maybe (giveup "Unknown remote") return
|
||||||
|
|
|
@ -19,7 +19,7 @@ cmd = noCommit $ noMessages $
|
||||||
|
|
||||||
run :: () -> String -> Annex Bool
|
run :: () -> String -> Annex Bool
|
||||||
run _ p = do
|
run _ p = do
|
||||||
let k = fromMaybe (giveup "bad key") $ file2key p
|
let k = fromMaybe (giveup "bad key") $ deserializeKey p
|
||||||
maybe (return False) (\f -> liftIO (putStrLn f) >> return True)
|
maybe (return False) (\f -> liftIO (putStrLn f) >> return True)
|
||||||
=<< inAnnex' (pure True) Nothing check k
|
=<< inAnnex' (pure True) Nothing check k
|
||||||
where
|
where
|
||||||
|
|
|
@ -38,7 +38,7 @@ seek o = do
|
||||||
Batch fmt -> batchInput fmt parsekey $ batchCommandAction . start
|
Batch fmt -> batchInput fmt parsekey $ batchCommandAction . start
|
||||||
NoBatch -> noop
|
NoBatch -> noop
|
||||||
where
|
where
|
||||||
parsekey = maybe (Left "bad key") Right . file2key
|
parsekey = maybe (Left "bad key") Right . deserializeKey
|
||||||
|
|
||||||
start :: Key -> CommandStart
|
start :: Key -> CommandStart
|
||||||
start key = do
|
start key = do
|
||||||
|
|
|
@ -79,7 +79,7 @@ mkKey :: String -> Key
|
||||||
mkKey s = case parseURI s of
|
mkKey s = case parseURI s of
|
||||||
Just u | not (isKeyPrefix (uriScheme u)) ->
|
Just u | not (isKeyPrefix (uriScheme u)) ->
|
||||||
Backend.URL.fromUrl s Nothing
|
Backend.URL.fromUrl s Nothing
|
||||||
_ -> case file2key s of
|
_ -> case deserializeKey s of
|
||||||
Just k -> k
|
Just k -> k
|
||||||
Nothing -> giveup $ "bad key/url " ++ s
|
Nothing -> giveup $ "bad key/url " ++ s
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ start [ks] = do
|
||||||
then exitSuccess
|
then exitSuccess
|
||||||
else exitFailure
|
else exitFailure
|
||||||
where
|
where
|
||||||
k = fromMaybe (giveup "bad key") (file2key ks)
|
k = fromMaybe (giveup "bad key") (deserializeKey ks)
|
||||||
locksuccess = liftIO $ do
|
locksuccess = liftIO $ do
|
||||||
putStrLn contentLockedMarker
|
putStrLn contentLockedMarker
|
||||||
hFlush stdout
|
hFlush stdout
|
||||||
|
|
|
@ -208,7 +208,7 @@ receive ups = do
|
||||||
|
|
||||||
storeReceived :: FilePath -> Annex ()
|
storeReceived :: FilePath -> Annex ()
|
||||||
storeReceived f = do
|
storeReceived f = do
|
||||||
case file2key (takeFileName f) of
|
case deserializeKey (takeFileName f) of
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
warning $ "Received a file " ++ f ++ " that is not a git-annex key. Deleting this file."
|
warning $ "Received a file " ++ f ++ " that is not a git-annex key. Deleting this file."
|
||||||
liftIO $ nukeFile f
|
liftIO $ nukeFile f
|
||||||
|
|
|
@ -43,7 +43,7 @@ batchParser :: String -> Either String (FilePath, Key)
|
||||||
batchParser s = case separate (== ' ') (reverse s) of
|
batchParser s = case separate (== ' ') (reverse s) of
|
||||||
(rk, rf)
|
(rk, rf)
|
||||||
| null rk || null rf -> Left "Expected: \"file key\""
|
| null rk || null rf -> Left "Expected: \"file key\""
|
||||||
| otherwise -> case file2key (reverse rk) of
|
| otherwise -> case deserializeKey (reverse rk) of
|
||||||
Nothing -> Left "bad key"
|
Nothing -> Left "bad key"
|
||||||
Just k -> Right (reverse rf, k)
|
Just k -> Right (reverse rf, k)
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ seek o = case batchOption o of
|
||||||
NoBatch -> withPairs (commandAction . start . parsekey) (reKeyThese o)
|
NoBatch -> withPairs (commandAction . start . parsekey) (reKeyThese o)
|
||||||
where
|
where
|
||||||
parsekey (file, skey) =
|
parsekey (file, skey) =
|
||||||
(file, fromMaybe (giveup "bad key") (file2key skey))
|
(file, fromMaybe (giveup "bad key") (deserializeKey skey))
|
||||||
|
|
||||||
start :: (FilePath, Key) -> CommandStart
|
start :: (FilePath, Key) -> CommandStart
|
||||||
start (file, newkey) = ifAnnexed file go stop
|
start (file, newkey) = ifAnnexed file go stop
|
||||||
|
|
|
@ -27,5 +27,5 @@ start (ks:us:[]) = do
|
||||||
then liftIO exitSuccess
|
then liftIO exitSuccess
|
||||||
else liftIO exitFailure
|
else liftIO exitFailure
|
||||||
where
|
where
|
||||||
k = fromMaybe (giveup "bad key") (file2key ks)
|
k = fromMaybe (giveup "bad key") (deserializeKey ks)
|
||||||
start _ = giveup "Wrong number of parameters"
|
start _ = giveup "Wrong number of parameters"
|
||||||
|
|
|
@ -26,7 +26,7 @@ start (keyname:file:[]) = do
|
||||||
start _ = giveup "specify a key and a content file"
|
start _ = giveup "specify a key and a content file"
|
||||||
|
|
||||||
mkKey :: String -> Key
|
mkKey :: String -> Key
|
||||||
mkKey = fromMaybe (giveup "bad key") . file2key
|
mkKey = fromMaybe (giveup "bad key") . deserializeKey
|
||||||
|
|
||||||
perform :: FilePath -> Key -> CommandPerform
|
perform :: FilePath -> Key -> CommandPerform
|
||||||
perform file key = do
|
perform file key = do
|
||||||
|
|
|
@ -40,7 +40,7 @@ data KeyStatus = KeyStatus Key UUID LogStatus
|
||||||
|
|
||||||
parseKeyStatus :: [String] -> Either String KeyStatus
|
parseKeyStatus :: [String] -> Either String KeyStatus
|
||||||
parseKeyStatus (ks:us:vs:[]) = do
|
parseKeyStatus (ks:us:vs:[]) = do
|
||||||
k <- maybe (Left "bad key") Right (file2key ks)
|
k <- maybe (Left "bad key") Right (deserializeKey ks)
|
||||||
let u = toUUID us
|
let u = toUUID us
|
||||||
s <- maybe (Left "bad value") Right (parseStatus vs)
|
s <- maybe (Left "bad value") Right (parseStatus vs)
|
||||||
return $ KeyStatus k u s
|
return $ KeyStatus k u s
|
||||||
|
|
|
@ -38,7 +38,7 @@ seek = withWords (commandAction . start)
|
||||||
-}
|
-}
|
||||||
start :: [String] -> CommandStart
|
start :: [String] -> CommandStart
|
||||||
start (k:[]) = do
|
start (k:[]) = do
|
||||||
case file2key k of
|
case deserializeKey k of
|
||||||
Nothing -> error "bad key"
|
Nothing -> error "bad key"
|
||||||
(Just key) -> whenM (inAnnex key) $ do
|
(Just key) -> whenM (inAnnex key) $ do
|
||||||
afile <- AssociatedFile <$> Fields.getField Fields.associatedFile
|
afile <- AssociatedFile <$> Fields.getField Fields.associatedFile
|
||||||
|
|
8
Key.hs
8
Key.hs
|
@ -14,8 +14,8 @@ module Key (
|
||||||
buildKey,
|
buildKey,
|
||||||
keyParser,
|
keyParser,
|
||||||
serializeKey,
|
serializeKey,
|
||||||
serializeKey,
|
serializeKey',
|
||||||
deserializeKey',
|
deserializeKey,
|
||||||
deserializeKey',
|
deserializeKey',
|
||||||
nonChunkKey,
|
nonChunkKey,
|
||||||
chunkKeyOffset,
|
chunkKeyOffset,
|
||||||
|
@ -179,8 +179,8 @@ instance Arbitrary Key where
|
||||||
<*> ((succ . abs <$>) <$> arbitrary) -- chunknum cannot be 0 or negative
|
<*> ((succ . abs <$>) <$> arbitrary) -- chunknum cannot be 0 or negative
|
||||||
|
|
||||||
instance Hashable Key where
|
instance Hashable Key where
|
||||||
hashIO32 = hashIO32 . deserializeKey'
|
hashIO32 = hashIO32 . serializeKey'
|
||||||
hashIO64 = hashIO64 . deserializeKey'
|
hashIO64 = hashIO64 . serializeKey'
|
||||||
|
|
||||||
instance ToJSON' Key where
|
instance ToJSON' Key where
|
||||||
toJSON' = toJSON' . serializeKey
|
toJSON' = toJSON' . serializeKey
|
||||||
|
|
|
@ -144,7 +144,7 @@ oldlog2key l
|
||||||
-- as the v2 key that it is.
|
-- as the v2 key that it is.
|
||||||
readKey1 :: String -> Key
|
readKey1 :: String -> Key
|
||||||
readKey1 v
|
readKey1 v
|
||||||
| mixup = fromJust $ file2key $ intercalate ":" $ Prelude.tail bits
|
| mixup = fromJust $ deserializeKey $ intercalate ":" $ Prelude.tail bits
|
||||||
| otherwise = stubKey
|
| otherwise = stubKey
|
||||||
{ keyName = encodeBS n
|
{ keyName = encodeBS n
|
||||||
, keyVariety = parseKeyVariety (encodeBS b)
|
, keyVariety = parseKeyVariety (encodeBS b)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue