avoid multiple unnecessary stats of the index file
Up to one per file processed.
This commit is contained in:
parent
8c87293b48
commit
5e2b4e16ba
3 changed files with 14 additions and 8 deletions
|
@ -268,7 +268,7 @@ withIndex' :: Bool -> Annex a -> Annex a
|
||||||
withIndex' bootstrapping a = do
|
withIndex' bootstrapping a = do
|
||||||
f <- fromRepo gitAnnexIndex
|
f <- fromRepo gitAnnexIndex
|
||||||
bracketIO (Git.Index.override f) id $ do
|
bracketIO (Git.Index.override f) id $ do
|
||||||
unlessM (liftIO $ doesFileExist f) $ do
|
checkIndexOnce $ unlessM (liftIO $ doesFileExist f) $ do
|
||||||
unless bootstrapping create
|
unless bootstrapping create
|
||||||
liftIO $ createDirectoryIfMissing True $ takeDirectory f
|
liftIO $ createDirectoryIfMissing True $ takeDirectory f
|
||||||
unless bootstrapping $ inRepo genIndex
|
unless bootstrapping $ inRepo genIndex
|
||||||
|
|
|
@ -37,6 +37,14 @@ invalidateCache = do
|
||||||
state <- getState
|
state <- getState
|
||||||
setState state { cachedFile = Nothing, cachedContent = "" }
|
setState state { cachedFile = Nothing, cachedContent = "" }
|
||||||
|
|
||||||
|
{- Runs an action to check that the index file exists, if it's not been
|
||||||
|
- checked before in this run of git-annex. -}
|
||||||
|
checkIndexOnce :: Annex () -> Annex ()
|
||||||
|
checkIndexOnce a = unlessM (indexChecked <$> getState) $ do
|
||||||
|
a
|
||||||
|
state <- getState
|
||||||
|
setState state { indexChecked = True }
|
||||||
|
|
||||||
{- Runs an action to update the branch, if it's not been updated before
|
{- Runs an action to update the branch, if it's not been updated before
|
||||||
- in this run of git-annex. -}
|
- in this run of git-annex. -}
|
||||||
runUpdateOnce :: Annex () -> Annex ()
|
runUpdateOnce :: Annex () -> Annex ()
|
||||||
|
@ -48,9 +56,6 @@ runUpdateOnce a = unlessM (branchUpdated <$> getState) $ do
|
||||||
- is known to have not changed, or git-annex won't be relying on info
|
- is known to have not changed, or git-annex won't be relying on info
|
||||||
- from it. -}
|
- from it. -}
|
||||||
disableUpdate :: Annex ()
|
disableUpdate :: Annex ()
|
||||||
disableUpdate = Annex.changeState setupdated
|
disableUpdate = do
|
||||||
where
|
state <- getState
|
||||||
setupdated s = s { Annex.branchstate = new }
|
setState state { branchUpdated = True }
|
||||||
where
|
|
||||||
new = old { branchUpdated = True }
|
|
||||||
old = Annex.branchstate s
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ module Types.BranchState where
|
||||||
|
|
||||||
data BranchState = BranchState {
|
data BranchState = BranchState {
|
||||||
branchUpdated :: Bool, -- has the branch been updated this run?
|
branchUpdated :: Bool, -- has the branch been updated this run?
|
||||||
|
indexChecked :: Bool, -- has the index file been checked to exist?
|
||||||
|
|
||||||
-- the content of one file is cached
|
-- the content of one file is cached
|
||||||
cachedFile :: Maybe FilePath,
|
cachedFile :: Maybe FilePath,
|
||||||
|
@ -16,4 +17,4 @@ data BranchState = BranchState {
|
||||||
}
|
}
|
||||||
|
|
||||||
startBranchState :: BranchState
|
startBranchState :: BranchState
|
||||||
startBranchState = BranchState False Nothing ""
|
startBranchState = BranchState False False Nothing ""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue