only do scan when there's a branch, not in freshly created new repo

This commit is contained in:
Joey Hess 2016-01-01 15:16:16 -04:00
parent e9a33088e8
commit 9b99595473
Failed to extract signature

View file

@ -38,6 +38,7 @@ import Utility.InodeCache
import Annex.InodeSentinal import Annex.InodeSentinal
import qualified Git.Types import qualified Git.Types
import qualified Git.LsTree import qualified Git.LsTree
import qualified Git.Branch
import Git.Ref import Git.Ref
import Git.FilePath import Git.FilePath
import Annex.CatFile import Annex.CatFile
@ -214,14 +215,15 @@ removeAssociatedFile' sk f = queueDb $
{- Find all unlocked associated files. This is expensive, and so normally {- Find all unlocked associated files. This is expensive, and so normally
- the associated files are updated incrementally when changes are noticed. -} - the associated files are updated incrementally when changes are noticed. -}
scanAssociatedFiles :: Annex () scanAssociatedFiles :: Annex ()
scanAssociatedFiles = runWriter $ \h -> do scanAssociatedFiles = whenM (isJust <$> inRepo Git.Branch.current) $
showSideAction "scanning for unlocked files" runWriter $ \h -> do
dropallassociated h showSideAction "scanning for unlocked files"
l <- inRepo $ Git.LsTree.lsTree headRef dropallassociated h
forM_ l $ \i -> l <- inRepo $ Git.LsTree.lsTree headRef
when (isregfile i) $ forM_ l $ \i ->
maybe noop (add h i) when (isregfile i) $
=<< catKey (Git.Types.Ref $ Git.LsTree.sha i) maybe noop (add h i)
=<< catKey (Git.Types.Ref $ Git.LsTree.sha i)
where where
dropallassociated = queueDb $ dropallassociated = queueDb $
delete $ from $ \(_r :: SqlExpr (Entity Associated)) -> delete $ from $ \(_r :: SqlExpr (Entity Associated)) ->