diff options
author | Joey Hess <joey@kitenet.net> | 2011-11-08 15:34:10 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-11-08 16:27:20 -0400 |
commit | bf460a0a98d7e4c7f4eac525fcf300629db582b6 (patch) | |
tree | bff7cd09529c40fa8cb76fd92428cc41e24ad808 /Remote/Hook.hs | |
parent | 2ff8915365099501382183af9855e739fc234861 (diff) |
reorder repo parameters last
Many functions took the repo as their first parameter. Changing it
consistently to be the last parameter allows doing some useful things with
currying, that reduce boilerplate.
In particular, g <- gitRepo is almost never needed now, instead
use inRepo to run an IO action in the repo, and fromRepo to get
a value from the repo.
This also provides more opportunities to use monadic and applicative
combinators.
Diffstat (limited to 'Remote/Hook.hs')
-rw-r--r-- | Remote/Hook.hs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/Remote/Hook.hs b/Remote/Hook.hs index 8b6a6cecf..06568a3cb 100644 --- a/Remote/Hook.hs +++ b/Remote/Hook.hs @@ -98,14 +98,13 @@ runHook hooktype hook k f a = maybe (return False) run =<< lookupHook hooktype h store :: String -> Key -> Annex Bool store h k = do - g <- gitRepo - runHook h "store" k (Just $ gitAnnexLocation g k) $ return True + src <- fromRepo $ gitAnnexLocation k + runHook h "store" k (Just src) $ return True storeEncrypted :: String -> (Cipher, Key) -> Key -> Annex Bool storeEncrypted h (cipher, enck) k = withTmp enck $ \tmp -> do - g <- gitRepo - let f = gitAnnexLocation g k - liftIO $ withEncryptedContent cipher (L.readFile f) $ \s -> L.writeFile tmp s + src <- fromRepo $ gitAnnexLocation k + liftIO $ withEncryptedContent cipher (L.readFile src) $ L.writeFile tmp runHook h "store" enck (Just tmp) $ return True retrieve :: String -> Key -> FilePath -> Annex Bool |