v6: Fix database inconsistency

That could cause git-annex to get confused about whether a locked file's
content was present, when the object file got touched.

Unfortunately this means more work sometimes when annex.thin is set,
since it has to checksum the file to tell if it's still got the right
content.

Had to suppress output when inAnnex calls isUnmodified, otherwise
"(checksum...)" would be printed in places it ought not to be,
eg "git annex get" could turn out not need to get anything, and
so only display that.

This commit was sponsored by Ole-Morten Duesund on Patreon.
This commit is contained in:
Joey Hess 2018-10-16 13:30:04 -04:00
parent 6498643caf
commit b2bafdb2fc
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
6 changed files with 76 additions and 29 deletions

View file

@ -16,6 +16,7 @@ module Messages (
showSideAction,
doSideAction,
doQuietSideAction,
doQuietAction,
showStoringStateAction,
showOutput,
showLongNote,
@ -111,11 +112,27 @@ doSideAction :: Annex a -> Annex a
doSideAction = doSideAction' StartBlock
doSideAction' :: SideActionBlock -> Annex a -> Annex a
doSideAction' b a = do
o <- Annex.getState Annex.output
set $ o { sideActionBlock = b }
set o `after` a
doSideAction' b = bracket setup cleanup . const
where
setup = do
o <- Annex.getState Annex.output
set $ o { sideActionBlock = b }
return o
cleanup = set
set o = Annex.changeState $ \s -> s { Annex.output = o }
{- Performs an action, suppressing all normal standard output,
- but not json output. -}
doQuietAction :: Annex a -> Annex a
doQuietAction = bracket setup cleanup . const
where
setup = do
o <- Annex.getState Annex.output
case outputType o of
NormalOutput -> set $ o { outputType = QuietOutput }
_ -> noop
return o
cleanup = set
set o = Annex.changeState $ \s -> s { Annex.output = o }
{- Make way for subsequent output of a command. -}