disable journal read optimisation when alwayscommit=false

The journal read optimisation in aeca7c220 later got fixed in eedd73b84
to stage and commit any files that were left in the journal by a
previous git-annex run. That's necessary for the optimisation to work
correctly. But it also meant that alwayscommit=false started committing
the previous git-annex processes journalled changes, which defeated the
purpose of the config setting entirely.

So, disable the optimisation when alwayscommit=false, leaving the
files in the journal and not committing them. See my comments on the bug
report for why this seemed the best approach.

Also fixes a problem when annex.merge-annex-branches=false and there
are changes in the journal. That config indirectly prevents committing
the journal. (Which seems a bit odd given its name, but it always has..)
So, when there were changes in the journal, perhaps left there due to
alwayscommit=false being set before, the optimisation would prevent
git-annex from reading the journal files, and it would operate with out
of date information.
This commit is contained in:
Joey Hess 2020-04-15 13:04:34 -04:00
parent 0e4c92503e
commit 43a9808292
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
5 changed files with 46 additions and 26 deletions

View file

@ -28,26 +28,24 @@ checkIndexOnce a = unlessM (indexChecked <$> getState) $ do
changeState $ \s -> s { indexChecked = True }
{- Runs an action to update the branch, if it's not been updated before
- in this run of git-annex. -}
runUpdateOnce :: Annex () -> Annex BranchState
- in this run of git-annex.
-
- The action should return True if anything that was in the journal
- before got staged (or if the journal was empty). That lets an opmisation
- be done: The journal then does not need to be checked going forward,
- until new information gets written to it.
-}
runUpdateOnce :: Annex Bool -> Annex BranchState
runUpdateOnce a = do
st <- getState
if branchUpdated st
then return st
else do
a
journalstaged <- a
let stf = \st' -> st'
{ branchUpdated = True
-- The update staged anything that was
-- journalled before, so the journal
-- does not need to be checked going
-- forward, unless new information
-- gets written to it, or unless
-- this run of git-annex needs to notice
-- changes journalled by other processes
-- while it's running.
, journalIgnorable = not $
journalNeverIgnorable st'
, journalIgnorable = journalstaged
&& not (journalNeverIgnorable st')
}
changeState stf
return (stf st)