summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-11-13 14:59:27 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-11-13 14:59:27 -0400
commit5fa25a812a8a03af9f6a5fdb3d06eb4d89ee06f5 (patch)
tree467341e52d23660eee3dc05c9935c961801374e5 /Command
parentd4d65a3c923de1eece50463145e875326bfe57e9 (diff)
fsck improvements
* fsck: Check if annex.numcopies is satisfied. * fsck: Verify the sha1 of files when the SHA1 backend is used. * fsck: Verify the size of files when the WORM backend is used. * fsck: Allow specifying individual files to fsk if fscking everything is not desired. * fsck: Fix bug, introduced in 0.04, in detection of unused data.
Diffstat (limited to 'Command')
-rw-r--r--Command/Fsck.hs9
-rw-r--r--Command/FsckFile.hs33
2 files changed, 37 insertions, 5 deletions
diff --git a/Command/Fsck.hs b/Command/Fsck.hs
index e5f0debe0..b0b9f7bb6 100644
--- a/Command/Fsck.hs
+++ b/Command/Fsck.hs
@@ -13,9 +13,10 @@ import Command
import Types
import Core
import Messages
+import qualified Command.FsckFile
seek :: [SubCmdSeek]
-seek = [withNothing start]
+seek = [withNothing start, withAll withFilesInGit Command.FsckFile.start]
{- Checks the whole annex for problems. -}
start :: SubCmdStart
@@ -26,11 +27,9 @@ start = do
perform :: SubCmdPerform
perform = do
ok <- checkUnused
- if (ok)
+ if ok
then return $ Just $ return True
- else do
- showLongNote "Possible problems detected."
- return Nothing
+ else return Nothing
checkUnused :: Annex Bool
checkUnused = do
diff --git a/Command/FsckFile.hs b/Command/FsckFile.hs
new file mode 100644
index 000000000..2f9efa56e
--- /dev/null
+++ b/Command/FsckFile.hs
@@ -0,0 +1,33 @@
+{- git-annex command
+ -
+ - Copyright 2010 Joey Hess <joey@kitenet.net>
+ -
+ - Licensed under the GNU GPL version 3 or higher.
+ -}
+
+module Command.FsckFile where
+
+import Command
+import qualified Backend
+import Types
+import Messages
+
+seek :: [SubCmdSeek]
+seek = [withFilesInGit start]
+
+{- Checks a file's backend data for problems. -}
+start :: SubCmdStartString
+start file = isAnnexed file $ \(key, backend) -> do
+ inbackend <- Backend.hasKey key
+ if (not inbackend)
+ then return Nothing
+ else do
+ showStart "fsck" file
+ return $ Just $ perform key backend
+
+perform :: Key -> Backend -> SubCmdPerform
+perform key backend = do
+ success <- Backend.fsckKey backend key
+ if (success)
+ then return $ Just $ return True
+ else return Nothing