convert fsckKey to a Maybe

This way it's clear when a backend does not implement its own fsck checks.
This commit is contained in:
Joey Hess 2012-01-19 13:51:30 -04:00
parent 50c063df06
commit d36525e974
5 changed files with 8 additions and 6 deletions

View file

@ -32,7 +32,7 @@ genBackend size
b = Backend b = Backend
{ name = shaName size { name = shaName size
, getKey = keyValue size , getKey = keyValue size
, fsckKey = checkKeyChecksum size , fsckKey = Just $ checkKeyChecksum size
} }
genBackendE :: SHASize -> Maybe Backend genBackendE :: SHASize -> Maybe Backend

View file

@ -21,7 +21,7 @@ backend :: Backend
backend = Backend { backend = Backend {
name = "URL", name = "URL",
getKey = const (return Nothing), getKey = const (return Nothing),
fsckKey = const (return True) fsckKey = Nothing
} }
fromUrl :: String -> Key fromUrl :: String -> Key

View file

@ -18,7 +18,7 @@ backend :: Backend
backend = Backend { backend = Backend {
name = "WORM", name = "WORM",
getKey = keyValue, getKey = keyValue,
fsckKey = const (return True) fsckKey = Nothing
} }
{- The key includes the file size, modification time, and the {- The key includes the file size, modification time, and the

View file

@ -137,7 +137,9 @@ checkKeySize key = do
checkBackend :: Backend -> Key -> Annex Bool 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 -> FilePath -> Maybe Int -> Annex Bool
checkKeyNumCopies key file numcopies = do checkKeyNumCopies key file numcopies = do

View file

@ -16,8 +16,8 @@ data BackendA a = Backend {
name :: String, name :: String,
-- converts a filename to a key -- converts a filename to a key
getKey :: FilePath -> a (Maybe Key), getKey :: FilePath -> a (Maybe Key),
-- called during fsck to check a key -- called during fsck to check a key, if the backend has its own checks
fsckKey :: Key -> a Bool fsckKey :: Maybe (Key -> a Bool)
} }
instance Show (BackendA a) where instance Show (BackendA a) where