factor out maybeAddJSONField

Sponsored-By: the NIH-funded NICEMAN (ReproNim TR&D3) project
This commit is contained in:
Joey Hess 2023-05-08 16:03:34 -04:00
parent 3d8f93dc0a
commit a5d0c85ae1
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
6 changed files with 22 additions and 18 deletions

View file

@ -35,7 +35,6 @@ import Annex.BloomFilter
import qualified Database.Keys
import Annex.InodeSentinal
import Utility.Aeson
import Messages.JSON (AddJSONActionItemField(..))
import qualified Data.Map as M
import qualified Data.Vector as V
@ -115,11 +114,9 @@ check fileprefix msg a c = do
let unusedlist = number c l
unless (null l) $
showLongNote $ UnquotedString $ msg unusedlist
let v = V.fromList $ map (\(n, k) -> (show n, serializeKey k)) unusedlist
let f = (if null fileprefix then "unused" else fileprefix) ++ "-list"
case toJSON' (AddJSONActionItemField f v) of
Object o -> maybeShowJSON $ AesonObject o
_ -> noop
maybeAddJSONField
((if null fileprefix then "unused" else fileprefix) ++ "-list")
(V.fromList $ map (\(n, k) -> (show n, serializeKey k)) unusedlist)
updateUnusedLog (toRawFilePath fileprefix) (M.fromList unusedlist)
return $ c + length l