diff options
author | Joey Hess <joey@kitenet.net> | 2011-07-15 12:47:14 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-07-15 12:47:14 -0400 |
commit | 6c396a256c93464d726c66a95132536941871ee8 (patch) | |
tree | 7f934c9eae22a9cfd3fb1672ebd7bf6870439c81 /Remote/Hook.hs | |
parent | 185f0b687081f47d059cc0503f4f6b671868f753 (diff) |
finished hlint pass
Diffstat (limited to 'Remote/Hook.hs')
-rw-r--r-- | Remote/Hook.hs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/Remote/Hook.hs b/Remote/Hook.hs index 86a7bca56..f0e4d5bfb 100644 --- a/Remote/Hook.hs +++ b/Remote/Hook.hs @@ -17,6 +17,7 @@ import System.Posix.IO import System.IO import System.IO.Error (try) import System.Exit +import Data.Maybe import Types import Types.Remote @@ -61,7 +62,7 @@ gen r u c = do hookSetup :: UUID -> RemoteConfig -> Annex RemoteConfig hookSetup u c = do - let hooktype = maybe (error "Specify hooktype=") id $ + let hooktype = fromMaybe (error "Specify hooktype=") $ M.lookup "hooktype" c c' <- encryptionSetup c gitConfigSpecialRemote u c' "hooktype" hooktype @@ -73,12 +74,13 @@ hookEnv k f = Just $ fileenv f ++ keyenv env s v = ("ANNEX_" ++ s, v) keyenv = [ env "KEY" (show k) - , env "HASH_1" (hashbits !! 0) - , env "HASH_2" (hashbits !! 1) + , env "HASH_1" hash_1 + , env "HASH_2" hash_2 ] fileenv Nothing = [] fileenv (Just file) = [env "FILE" file] - hashbits = map takeDirectory $ splitPath $ hashDirMixed k + [hash_1, hash_2, _rest] = + map takeDirectory $ splitPath $ hashDirMixed k lookupHook :: String -> String -> Annex (Maybe String) lookupHook hooktype hook =do @@ -127,7 +129,7 @@ retrieveEncrypted h (cipher, enck) f = withTmp enck $ \tmp -> return True remove :: String -> Key -> Annex Bool -remove h k = runHook h "remove" k Nothing $ do return True +remove h k = runHook h "remove" k Nothing $ return True checkPresent :: Git.Repo -> String -> Key -> Annex (Either IOException Bool) checkPresent r h k = do @@ -135,7 +137,7 @@ checkPresent r h k = do v <- lookupHook h "checkpresent" liftIO (try (check v) ::IO (Either IOException Bool)) where - findkey s = (show k) `elem` (lines s) + findkey s = show k `elem` lines s env = hookEnv k Nothing check Nothing = error "checkpresent hook misconfigured" check (Just hook) = do @@ -150,5 +152,5 @@ checkPresent r h k = do hClose fromh s <- getProcessStatus True False pid case s of - Just (Exited (ExitSuccess)) -> return $ findkey reply + Just (Exited ExitSuccess) -> return $ findkey reply _ -> error "checkpresent hook failed" |