summaryrefslogtreecommitdiff
path: root/Command/Fsck.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-11-08 15:34:10 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-11-08 16:27:20 -0400
commitbf460a0a98d7e4c7f4eac525fcf300629db582b6 (patch)
treebff7cd09529c40fa8cb76fd92428cc41e24ad808 /Command/Fsck.hs
parent2ff8915365099501382183af9855e739fc234861 (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 'Command/Fsck.hs')
-rw-r--r--Command/Fsck.hs20
1 files changed, 10 insertions, 10 deletions
diff --git a/Command/Fsck.hs b/Command/Fsck.hs
index d1abb29e3..3feabeb9e 100644
--- a/Command/Fsck.hs
+++ b/Command/Fsck.hs
@@ -79,26 +79,26 @@ check = sequence >=> dispatch
in this repository only. -}
verifyLocationLog :: Key -> String -> Annex Bool
verifyLocationLog key desc = do
- g <- gitRepo
present <- inAnnex key
-- Since we're checking that a key's file is present, throw
-- in a permission fixup here too.
- when present $ liftIO $ do
- let f = gitAnnexLocation g key
- preventWrite f
- preventWrite (parentDir f)
+ when present $ do
+ f <- fromRepo $ gitAnnexLocation key
+ liftIO $ do
+ preventWrite f
+ preventWrite (parentDir f)
u <- getUUID
uuids <- keyLocations key
case (present, u `elem` uuids) of
(True, False) -> do
- fix g u InfoPresent
+ fix u InfoPresent
-- There is no data loss, so do not fail.
return True
(False, True) -> do
- fix g u InfoMissing
+ fix u InfoMissing
warning $
"** Based on the location log, " ++ desc
++ "\n** was expected to be present, " ++
@@ -107,16 +107,16 @@ verifyLocationLog key desc = do
_ -> return True
where
- fix g u s = do
+ fix u s = do
showNote "fixing location log"
+ g <- gitRepo
logChange g key u s
{- The size of the data for a key is checked against the size encoded in
- the key's metadata, if available. -}
checkKeySize :: Key -> Annex Bool
checkKeySize key = do
- g <- gitRepo
- let file = gitAnnexLocation g key
+ file <- fromRepo $ gitAnnexLocation key
present <- liftIO $ doesFileExist file
case (present, Types.Key.keySize key) of
(_, Nothing) -> return True