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
Annex
CmdLine

View file

@ -20,6 +20,7 @@ module Annex.Branch (
updateTo, updateTo,
get, get,
getHistorical, getHistorical,
getUnmergedRefs,
RegardingUUID(..), RegardingUUID(..),
change, change,
maybeChange, maybeChange,
@ -281,6 +282,12 @@ get file = do
bs <- forM refs $ \ref -> getRef ref file bs <- forM refs $ \ref -> getRef ref file
return (l <> mconcat bs) return (l <> mconcat bs)
{- When the git-annex branch is unable to be updated due to permissions,
- and there are other git-annex branches that have not been merged into
- it, this gets the refs of those branches. -}
getUnmergedRefs :: Annex [Git.Ref]
getUnmergedRefs = unmergedRefs <$> update
{- Used to cache the value of a file, which has been read from the branch {- Used to cache the value of a file, which has been read from the branch
- using some optimised method. The journal has to be checked, in case - using some optimised method. The journal has to be checked, in case
- it has a newer version of the file that has not reached the branch yet. - it has a newer version of the file that has not reached the branch yet.

View file

@ -361,13 +361,14 @@ seekFilteredKeys seeker listfs = do
(process mi ofeeder mdfeeder mdcloser False l) (process mi ofeeder mdfeeder mdcloser False l)
mdprocessertid <- liftIO . async =<< forkState mdprocessertid <- liftIO . async =<< forkState
(mdprocess mi mdreader ofeeder ocloser) (mdprocess mi mdreader ofeeder ocloser)
if usesLocationLog seeker || matcherNeedsLocationLog mi ifM (precachell mi)
then catObjectStream g $ \lfeeder lcloser lreader -> do ( catObjectStream g $ \lfeeder lcloser lreader -> do
precachertid <- liftIO . async =<< forkState precachertid <- liftIO . async =<< forkState
(precacher mi config oreader lfeeder lcloser) (precacher mi config oreader lfeeder lcloser)
precachefinisher mi lreader checktimelimit precachefinisher mi lreader checktimelimit
join (liftIO (wait precachertid)) join (liftIO (wait precachertid))
else finisher mi oreader checktimelimit , finisher mi oreader checktimelimit
)
join (liftIO (wait mdprocessertid)) join (liftIO (wait mdprocessertid))
join (liftIO (wait processertid)) join (liftIO (wait processertid))
liftIO $ void cleanup liftIO $ void cleanup
@ -467,6 +468,16 @@ seekFilteredKeys seeker listfs = do
Just _ -> mdprocess mi mdreader ofeeder ocloser Just _ -> mdprocess mi mdreader ofeeder ocloser
Nothing -> liftIO $ void 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 :: (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 seekHelper c ww a (WorkTreeItems l) = do
os <- seekOptions ww os <- seekOptions ww