summaryrefslogtreecommitdiff
path: root/Annex
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-01-19 17:05:39 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-01-19 17:10:44 -0400
commiteffaa298fabed963ec8a616d206662682e70e61a (patch)
treece77bdefce496d3df63c63fe967d2f79b170b53a /Annex
parentf35a84fac750d8e246f3fcd1f25054951eff8b7e (diff)
optimise fsck --from normal git remotes
For a local git remote, can symlink the file. For a git remote using rsync, can preseed any local content. There are a few reasons to use fsck --from on a normal git remote. One is if it's using gitosis or similar, and you don't have shell access to run git annex locally. Another reason could be if you just want to fsck certian files of a bare remote.
Diffstat (limited to 'Annex')
-rw-r--r--Annex/Content.hs11
1 files changed, 11 insertions, 0 deletions
diff --git a/Annex/Content.hs b/Annex/Content.hs
index ba67a2f15..efd360a09 100644
--- a/Annex/Content.hs
+++ b/Annex/Content.hs
@@ -22,6 +22,7 @@ module Annex.Content (
getKeysPresent,
saveState,
downloadUrl,
+ preseedTmp,
) where
import System.IO.Error (try)
@@ -40,6 +41,7 @@ import Utility.FileMode
import qualified Utility.Url as Url
import Types.Key
import Utility.DataUnits
+import Utility.CopyFile
import Config
import Annex.Exception
@@ -301,3 +303,12 @@ downloadUrl urls file = do
g <- gitRepo
o <- map Param . words <$> getConfig g "web-options" ""
liftIO $ anyM (\u -> Url.download u o file) urls
+
+{- 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