summaryrefslogtreecommitdiff
path: root/Command/Fsck.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-01-20 13:23:11 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-01-20 13:23:11 -0400
commit61dbad505d648f13394018c31ce2d718c175007e (patch)
tree96f087d5ec3e3eab6cf45b5a7d49cfb2b0dfa7f7 /Command/Fsck.hs
parente96726caa31fd76413b450790860611f71d13915 (diff)
fsck --from remote --fast
Avoids expensive file transfers, at the expense of checking file size and/or contents. Required some reworking of the remote code.
Diffstat (limited to 'Command/Fsck.hs')
-rw-r--r--Command/Fsck.hs14
1 files changed, 12 insertions, 2 deletions
diff --git a/Command/Fsck.hs b/Command/Fsck.hs
index 9d856ce88..59af29edb 100644
--- a/Command/Fsck.hs
+++ b/Command/Fsck.hs
@@ -9,6 +9,7 @@ module Command.Fsck where
import Common.Annex
import Command
+import qualified Annex
import qualified Remote
import qualified Types.Backend
import qualified Types.Key
@@ -65,8 +66,8 @@ performRemote key file backend numcopies remote = do
showNote err
stop
Right True -> withtmp $ \tmpfile -> do
- copied <- Remote.retrieveKeyFile remote key True tmpfile
- if copied then go True (Just tmpfile) else go False Nothing
+ copied <- getfile tmpfile
+ if copied then go True (Just tmpfile) else go True Nothing
Right False -> go False Nothing
where
go present localcopy = check
@@ -83,6 +84,15 @@ performRemote key file backend numcopies remote = do
let cleanup = liftIO $ catch (removeFile tmp) (const $ return ())
cleanup
cleanup `after` a tmp
+ getfile tmp = do
+ ok <- Remote.retrieveKeyFileCheap remote key tmp
+ if ok
+ then return ok
+ else do
+ fast <- Annex.getState Annex.fast
+ if fast
+ then return False
+ else Remote.retrieveKeyFile remote key tmp
{- To fsck a bare repository, fsck each key in the location log. -}
withBarePresentKeys :: (Key -> CommandStart) -> CommandSeek