diff options
author | 2011-03-23 02:10:59 -0400 | |
---|---|---|
committer | 2011-03-23 02:10:59 -0400 | |
commit | c43e3b5c787050664089fa4498e660a475addcd9 (patch) | |
tree | 3da57db088d99ac43c81245c9fd605ddf2854eda /Backend | |
parent | 12cdc96216e0c516ceeee922f9ca1568e9d4d592 (diff) |
check key size when available, no matter the backend
Now that SHA and other backends can have size info, fsck should check it
whenever available.
Diffstat (limited to 'Backend')
-rw-r--r-- | Backend/File.hs | 5 | ||||
-rw-r--r-- | Backend/WORM.hs | 27 |
2 files changed, 5 insertions, 27 deletions
diff --git a/Backend/File.hs b/Backend/File.hs index a5e243199..a6d42eabd 100644 --- a/Backend/File.hs +++ b/Backend/File.hs @@ -38,7 +38,7 @@ backend = Backend { retrieveKeyFile = copyKeyFile, removeKey = checkRemoveKey, hasKey = inAnnex, - fsckKey = mustProvide + fsckKey = checkKeyOnly } mustProvide :: a @@ -172,6 +172,9 @@ checkKey a key file numcopies = do copies_ok <- checkKeyNumCopies key file numcopies return $ a_ok && copies_ok +checkKeyOnly :: Key -> Maybe FilePath -> Maybe Int -> Annex Bool +checkKeyOnly = checkKey (\_ -> return True) + checkKeyNumCopies :: Key -> Maybe FilePath -> Maybe Int -> Annex Bool checkKeyNumCopies key file numcopies = do needed <- getNumCopies numcopies diff --git a/Backend/WORM.hs b/Backend/WORM.hs index a011995da..b33c60763 100644 --- a/Backend/WORM.hs +++ b/Backend/WORM.hs @@ -10,15 +10,9 @@ module Backend.WORM (backends) where import Control.Monad.State import System.FilePath import System.Posix.Files -import System.Directory -import Data.Maybe import qualified Backend.File import BackendClass -import Locations -import qualified Annex -import Content -import Messages import Types import Key @@ -28,8 +22,7 @@ backends = [backend] backend :: Backend Annex backend = Backend.File.backend { name = "WORM", - getKey = keyValue, - fsckKey = Backend.File.checkKey checkKeySize + getKey = keyValue } {- The key includes the file size, modification time, and the @@ -48,21 +41,3 @@ keyValue file = do keySize = Just $ fromIntegral $ fileSize stat, keyMtime = Just $ modificationTime stat } - -{- The size of the data for a key is checked against the size encoded in - - the key's metadata. -} -checkKeySize :: Key -> Annex Bool -checkKeySize key = do - g <- Annex.gitRepo - let file = gitAnnexLocation g key - present <- liftIO $ doesFileExist file - if not present - then return True - else do - s <- liftIO $ getFileStatus file - if fromIntegral (fileSize s) == fromJust (keySize key) - then return True - else do - dest <- moveBad key - warning $ "Bad file size; moved to " ++ dest - return False |