summaryrefslogtreecommitdiff
path: root/Annex
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 /Annex
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 'Annex')
-rw-r--r--Annex/Content.hs21
1 files changed, 15 insertions, 6 deletions
diff --git a/Annex/Content.hs b/Annex/Content.hs
index efd360a09..c21ac405e 100644
--- a/Annex/Content.hs
+++ b/Annex/Content.hs
@@ -306,9 +306,18 @@ downloadUrl urls file = do
{- Copies a key's content, when present, to a temp file.
- This is used to speed up some rsyncs. -}
-preseedTmp :: Key -> FilePath -> Annex ()
-preseedTmp key file =
- unlessM (liftIO $ doesFileExist file) $ whenM (inAnnex key) $ do
- s <- inRepo $ gitAnnexLocation key
- liftIO $ whenM (copyFileExternal s file) $
- allowWrite file
+preseedTmp :: Key -> FilePath -> Annex Bool
+preseedTmp key file = go =<< inAnnex key
+ where
+ go False = return False
+ go True = do
+ ok <- copy
+ when ok $ liftIO $ allowWrite file
+ return ok
+ copy = do
+ present <- liftIO $ doesFileExist file
+ if present
+ then return True
+ else do
+ s <- inRepo $ gitAnnexLocation key
+ liftIO $ copyFileExternal s file