Sped up git-annex add in direct mode and v6 by using git hash-object --batch.
Speeds up hashSymlink and hashPointerFile.
This commit is contained in:
parent
f2772f469a
commit
88a4a6f396
6 changed files with 25 additions and 33 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue