summaryrefslogtreecommitdiff
path: root/Command
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
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')
-rw-r--r--Command/Fsck.hs14
-rw-r--r--Command/Get.hs2
-rw-r--r--Command/Move.hs2
3 files changed, 14 insertions, 4 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
diff --git a/Command/Get.hs b/Command/Get.hs
index 7f5c08a7e..5d032e13c 100644
--- a/Command/Get.hs
+++ b/Command/Get.hs
@@ -72,7 +72,7 @@ getKeyFile key file = do
else return True
docopy r continue = do
showAction $ "from " ++ Remote.name r
- copied <- Remote.retrieveKeyFile r key False file
+ copied <- Remote.retrieveKeyFile r key file
if copied
then return True
else continue
diff --git a/Command/Move.hs b/Command/Move.hs
index 003ca27b8..2f2cd1b5d 100644
--- a/Command/Move.hs
+++ b/Command/Move.hs
@@ -131,7 +131,7 @@ fromPerform src move key = moveLock move key $ do
then handle move True
else do
showAction $ "from " ++ Remote.name src
- ok <- getViaTmp key $ Remote.retrieveKeyFile src key False
+ ok <- getViaTmp key $ Remote.retrieveKeyFile src key
handle move ok
where
handle _ False = stop -- failed