disable precaching git-annex branch when there are unmerged branches in a read-only repo

The way precaching works, it can't merge in information from those
branches efficiently, so just disable it and fall back to
Annex.Branch.get in order to get the correct information.

Sponsored-by: Dartmouth College's Datalad project
This commit is contained in:
Joey Hess 2021-12-27 14:08:50 -04:00
parent 6b7601c7f6
commit d9d0fe5fa4
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 21 additions and 3 deletions

View file

@ -361,13 +361,14 @@ seekFilteredKeys seeker listfs = do
(process mi ofeeder mdfeeder mdcloser False l)
mdprocessertid <- liftIO . async =<< forkState
(mdprocess mi mdreader ofeeder ocloser)
if usesLocationLog seeker || matcherNeedsLocationLog mi
then catObjectStream g $ \lfeeder lcloser lreader -> do
ifM (precachell mi)
( catObjectStream g $ \lfeeder lcloser lreader -> do
precachertid <- liftIO . async =<< forkState
(precacher mi config oreader lfeeder lcloser)
precachefinisher mi lreader checktimelimit
join (liftIO (wait precachertid))
else finisher mi oreader checktimelimit
, finisher mi oreader checktimelimit
)
join (liftIO (wait mdprocessertid))
join (liftIO (wait processertid))
liftIO $ void cleanup
@ -467,6 +468,16 @@ seekFilteredKeys seeker listfs = do
Just _ -> mdprocess mi mdreader ofeeder ocloser
Nothing -> liftIO $ void ocloser
-- Precache location logs if it will speed things up.
--
-- When there are git-annex branches that are not able to be
-- merged, the precaching is disabled, since it only looks at the
-- git-annex branch and not at those.
precachell mi
| usesLocationLog seeker || matcherNeedsLocationLog mi =
null <$> Annex.Branch.getUnmergedRefs
| otherwise = pure False
seekHelper :: (a -> RawFilePath) -> WarnUnmatchWhen -> ([LsFiles.Options] -> [RawFilePath] -> Git.Repo -> IO ([a], IO Bool)) -> WorkTreeItems -> Annex ([(SeekInput, a)], IO Bool)
seekHelper c ww a (WorkTreeItems l) = do
os <- seekOptions ww