From 90db9740d0d64b34f2e46f57f8aaca235088734c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 14 Mar 2016 15:58:46 -0400 Subject: Sped up git-annex add in direct mode and v6 by using git hash-object --batch. Speeds up hashSymlink and hashPointerFile. --- Annex/HashObject.hs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'Annex/HashObject.hs') diff --git a/Annex/HashObject.hs b/Annex/HashObject.hs index aa8c2a174..16f741407 100644 --- a/Annex/HashObject.hs +++ b/Annex/HashObject.hs @@ -12,38 +12,31 @@ module Annex.HashObject ( hashObjectStop, ) where -import qualified Data.ByteString.Lazy as L -import qualified Data.Map as M -import System.PosixCompat.Types - import Annex.Common -import qualified Git import qualified Git.HashObject import qualified Annex import Git.Types -import Git.FilePath -import qualified Git.Ref -import Annex.Link hashObjectHandle :: Annex Git.HashObject.HashObjectHandle hashObjectHandle = maybe startup return =<< Annex.getState Annex.hashobjecthandle where startup = do - inRepo $ Git.hashObjectStart + h <- inRepo $ Git.HashObject.hashObjectStart Annex.changeState $ \s -> s { Annex.hashobjecthandle = Just h } return h hashObjectStop :: Annex () -hashObjectStop = maybe noop stop =<< Annex.hashobjecthandle +hashObjectStop = maybe noop stop =<< Annex.getState Annex.hashobjecthandle where stop h = do - liftIO $ Git.hashObjectStop h + liftIO $ Git.HashObject.hashObjectStop h Annex.changeState $ \s -> s { Annex.hashobjecthandle = Nothing } + return () hashFile :: FilePath -> Annex Sha hashFile f = do h <- hashObjectHandle - Git.HashObject.hashFile h f + liftIO $ Git.HashObject.hashFile h f {- Note that the content will be written to a temp file. - So it may be faster to use Git.HashObject.hashObject for large @@ -51,4 +44,4 @@ hashFile f = do hashBlob :: String -> Annex Sha hashBlob content = do h <- hashObjectHandle - Git.HashObject.hashFile h content + liftIO $ Git.HashObject.hashBlob h content -- cgit v1.2.3