summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-01-19 13:51:30 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-01-19 13:51:30 -0400
commitd36525e9745b90cc04abfeac6500ff646cb9c89b (patch)
treeb497b310b7e9da8e00859a9eed616b36c297c07b
parent50c063df069682bdac2af3b1746933da70a519b8 (diff)
convert fsckKey to a Maybe
This way it's clear when a backend does not implement its own fsck checks.
-rw-r--r--Backend/SHA.hs2
-rw-r--r--Backend/URL.hs2
-rw-r--r--Backend/WORM.hs2
-rw-r--r--Command/Fsck.hs4
-rw-r--r--Types/Backend.hs4
5 files changed, 8 insertions, 6 deletions
diff --git a/Backend/SHA.hs b/Backend/SHA.hs
index a1124dfe2..29f4e2e94 100644
--- a/Backend/SHA.hs
+++ b/Backend/SHA.hs
@@ -32,7 +32,7 @@ genBackend size
b = Backend
{ name = shaName size
, getKey = keyValue size
- , fsckKey = checkKeyChecksum size
+ , fsckKey = Just $ checkKeyChecksum size
}
genBackendE :: SHASize -> Maybe Backend
diff --git a/Backend/URL.hs b/Backend/URL.hs
index 7f621b00f..6406095ca 100644
--- a/Backend/URL.hs
+++ b/Backend/URL.hs
@@ -21,7 +21,7 @@ backend :: Backend
backend = Backend {
name = "URL",
getKey = const (return Nothing),
- fsckKey = const (return True)
+ fsckKey = Nothing
}
fromUrl :: String -> Key
diff --git a/Backend/WORM.hs b/Backend/WORM.hs
index ae9833e30..c022fd413 100644
--- a/Backend/WORM.hs
+++ b/Backend/WORM.hs
@@ -18,7 +18,7 @@ backend :: Backend
backend = Backend {
name = "WORM",
getKey = keyValue,
- fsckKey = const (return True)
+ fsckKey = Nothing
}
{- The key includes the file size, modification time, and the
diff --git a/Command/Fsck.hs b/Command/Fsck.hs
index 680828748..051a58fb4 100644
--- a/Command/Fsck.hs
+++ b/Command/Fsck.hs
@@ -137,7 +137,9 @@ checkKeySize key = do
checkBackend :: Backend -> Key -> Annex Bool
-checkBackend = Types.Backend.fsckKey
+checkBackend backend key = case Types.Backend.fsckKey backend of
+ Nothing -> return True
+ Just a -> a key
checkKeyNumCopies :: Key -> FilePath -> Maybe Int -> Annex Bool
checkKeyNumCopies key file numcopies = do
diff --git a/Types/Backend.hs b/Types/Backend.hs
index 025293a90..1966d667f 100644
--- a/Types/Backend.hs
+++ b/Types/Backend.hs
@@ -16,8 +16,8 @@ data BackendA a = Backend {
name :: String,
-- converts a filename to a key
getKey :: FilePath -> a (Maybe Key),
- -- called during fsck to check a key
- fsckKey :: Key -> a Bool
+ -- called during fsck to check a key, if the backend has its own checks
+ fsckKey :: Maybe (Key -> a Bool)
}
instance Show (BackendA a) where