summaryrefslogtreecommitdiff
path: root/Backend
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-04-07 21:47:56 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-04-07 21:47:56 -0400
commitb889543507959c0a311bc8387f78ec4c0e93f7a8 (patch)
treee51d144458d551a0232572ed89ef795f907ae9c1 /Backend
parentf5b2d650bb75dc7ca2f77dae59fb1ab7f7405e03 (diff)
let's use Maybe String for commands that may not be avilable
Diffstat (limited to 'Backend')
-rw-r--r--Backend/SHA.hs12
1 files changed, 6 insertions, 6 deletions
diff --git a/Backend/SHA.hs b/Backend/SHA.hs
index 42b5efeff..d9aeb72aa 100644
--- a/Backend/SHA.hs
+++ b/Backend/SHA.hs
@@ -27,7 +27,7 @@ import qualified SysConfig
import Key
type SHASize = Int
-
+
backends :: [Backend Annex]
-- order is slightly significant; want sha1 first ,and more general
-- sizes earlier
@@ -35,8 +35,8 @@ backends = catMaybes $ map genBackend [1, 256, 512, 224, 384]
genBackend :: SHASize -> Maybe (Backend Annex)
genBackend size
- | shaCommand size /= "" = Just b
- | otherwise = Nothing
+ | shaCommand size == Nothing = Nothing
+ | otherwise = Just b
where
b = Backend.File.backend
{ name = shaName size
@@ -44,13 +44,13 @@ genBackend size
, fsckKey = Backend.File.checkKey $ checkKeyChecksum size
}
-shaCommand :: SHASize -> String
+shaCommand :: SHASize -> Maybe String
shaCommand 1 = SysConfig.sha1
shaCommand 256 = SysConfig.sha256
shaCommand 224 = SysConfig.sha224
shaCommand 384 = SysConfig.sha384
shaCommand 512 = SysConfig.sha512
-shaCommand _ = ""
+shaCommand _ = Nothing
shaName :: SHASize -> String
shaName size = "SHA" ++ show size
@@ -65,7 +65,7 @@ shaN size file = do
then error $ command ++ " parse error"
else return $ head bits
where
- command = shaCommand size
+ command = fromJust $ shaCommand size
{- A key is a checksum of its contents. -}
keyValue :: SHASize -> FilePath -> Annex (Maybe Key)