filter out control characters in all other Messages

This does, as a side effect, make long notes in json output not
be indented. The indentation is only needed to offset them
underneath the display of the file they apply to, so that's ok.

Sponsored-by: Brock Spratlen on Patreon
This commit is contained in:
Joey Hess 2023-04-10 17:03:41 -04:00
parent a0e6fa18eb
commit 8b6c7bdbcc
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
54 changed files with 183 additions and 164 deletions

View file

@ -159,15 +159,15 @@ performRemote key afile backend numcopies remote =
dispatch =<< Remote.hasKey remote key
where
dispatch (Left err) = do
showNote err
showNote (UnquotedString err)
return False
dispatch (Right True) = withtmp $ \tmpfile ->
getfile tmpfile >>= \case
Nothing -> go True Nothing
Just (Right verification) -> go True (Just (tmpfile, verification))
Just (Left _) -> do
qp <- coreQuotePath <$> Annex.getGitConfig
warning $ UnquotedString (decodeBS (actionItemDesc qp ai)) <> ": failed to download file from remote"
warning $ actionItemDesc ai
<> ": failed to download file from remote"
void $ go True Nothing
return False
dispatch (Right False) = go False Nothing
@ -350,10 +350,9 @@ verifyLocationLog' key ai present u updatestatus = do
return True
(False, True) -> do
fix InfoMissing
qp <- coreQuotePath <$> Annex.getGitConfig
warning $
"** Based on the location log, " <>
QuotedPath (actionItemDesc qp ai) <>
actionItemDesc ai <>
"\n** was expected to be present, " <>
"but its content is missing."
return False
@ -390,11 +389,10 @@ verifyRequiredContent key ai@(ActionItemAssociatedFile afile _) = case afile of
if null missinglocs
then return True
else do
qp <- coreQuotePath <$> Annex.getGitConfig
missingrequired <- Remote.prettyPrintUUIDs "missingrequired" missinglocs
warning $
"** Required content " <>
QuotedPath (actionItemDesc qp ai) <>
actionItemDesc ai <>
" is missing from these repositories:\n" <>
UnquotedString missingrequired
return False
@ -467,9 +465,7 @@ checkKeySizeOr bad key file ai = case fromKey keySize key of
return same
badsize a b = do
msg <- bad key
qp <- coreQuotePath <$> Annex.getGitConfig
warning $
QuotedPath (actionItemDesc qp ai)
warning $ actionItemDesc ai
<> ": Bad file size ("
<> UnquotedString (compareSizes storageUnits True a b)
<> "); "
@ -485,12 +481,10 @@ checkKeyUpgrade :: Backend -> Key -> ActionItem -> AssociatedFile -> Annex Bool
checkKeyUpgrade backend key ai (AssociatedFile (Just file)) =
case Types.Backend.canUpgradeKey backend of
Just a | a key -> do
qp <- coreQuotePath <$> Annex.getGitConfig
warning $
QuotedPath (actionItemDesc qp ai)
warning $ actionItemDesc ai
<> ": Can be upgraded to an improved key format. "
<> "You can do so by running: git annex migrate --backend="
<> UnquotedString (decodeBS (formatKeyVariety (fromKey keyVariety key)))
<> UnquotedByteString (formatKeyVariety (fromKey keyVariety key))
<> " "
<> QuotedPath file
return True
@ -537,9 +531,7 @@ checkBackendOr bad backend key file ai =
ok <- verifier key file
unless ok $ do
msg <- bad key
qp <- coreQuotePath <$> Annex.getGitConfig
warning $
QuotedPath (actionItemDesc qp ai)
warning $ actionItemDesc ai
<> ": Bad file content; "
<> UnquotedString msg
return ok
@ -565,9 +557,7 @@ checkInodeCache key content mic ai = case mic of
withTSDelta (liftIO . genInodeCache content) >>= \case
Nothing -> noop
Just ic' -> whenM (compareInodeCaches ic ic') $ do
qp <- coreQuotePath <$> Annex.getGitConfig
warning $
QuotedPath (actionItemDesc qp ai)
warning $ actionItemDesc ai
<> ": Stale or missing inode cache; updating."
Database.Keys.addInodeCaches key [ic]