From 686fc71dbddff72fa7a0e33d7dabad469bc620e4 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 1 Jan 2016 15:16:16 -0400 Subject: only do scan when there's a branch, not in freshly created new repo --- Database/Keys.hs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Database/Keys.hs b/Database/Keys.hs index 30e6ff921..0cd7401be 100644 --- a/Database/Keys.hs +++ b/Database/Keys.hs @@ -38,6 +38,7 @@ import Utility.InodeCache import Annex.InodeSentinal import qualified Git.Types import qualified Git.LsTree +import qualified Git.Branch import Git.Ref import Git.FilePath import Annex.CatFile @@ -214,14 +215,15 @@ removeAssociatedFile' sk f = queueDb $ {- Find all unlocked associated files. This is expensive, and so normally - the associated files are updated incrementally when changes are noticed. -} scanAssociatedFiles :: Annex () -scanAssociatedFiles = runWriter $ \h -> do - showSideAction "scanning for unlocked files" - dropallassociated h - l <- inRepo $ Git.LsTree.lsTree headRef - forM_ l $ \i -> - when (isregfile i) $ - maybe noop (add h i) - =<< catKey (Git.Types.Ref $ Git.LsTree.sha i) +scanAssociatedFiles = whenM (isJust <$> inRepo Git.Branch.current) $ + runWriter $ \h -> do + showSideAction "scanning for unlocked files" + dropallassociated h + l <- inRepo $ Git.LsTree.lsTree headRef + forM_ l $ \i -> + when (isregfile i) $ + maybe noop (add h i) + =<< catKey (Git.Types.Ref $ Git.LsTree.sha i) where dropallassociated = queueDb $ delete $ from $ \(_r :: SqlExpr (Entity Associated)) -> -- cgit v1.2.3