factor out maybeAddJSONField
Sponsored-By: the NIH-funded NICEMAN (ReproNim TR&D3) project
This commit is contained in:
parent
3d8f93dc0a
commit
a5d0c85ae1
6 changed files with 22 additions and 18 deletions
|
@ -12,11 +12,10 @@ import Annex.MetaData
|
|||
import Annex.VectorClock
|
||||
import Logs.MetaData
|
||||
import Annex.WorkTree
|
||||
import Messages.JSON (JSONActionItem(..), AddJSONActionItemField(..))
|
||||
import Types.Messages
|
||||
import Utility.Aeson
|
||||
import Utility.SafeOutput
|
||||
import Limit
|
||||
import Messages.JSON (JSONActionItem(..), eitherDecode)
|
||||
|
||||
import qualified Data.Set as S
|
||||
import qualified Data.Map as M
|
||||
|
@ -127,9 +126,7 @@ perform c o k = case getSet o of
|
|||
cleanup :: Key -> CommandCleanup
|
||||
cleanup k = do
|
||||
m <- getCurrentMetaData k
|
||||
case toJSON' (AddJSONActionItemField "fields" m) of
|
||||
Object o -> maybeShowJSON $ AesonObject o
|
||||
_ -> noop
|
||||
maybeAddJSONField "fields" m
|
||||
showLongNote $ UnquotedString $ unlines $ concatMap showmeta $
|
||||
map unwrapmeta (fromMetaData m)
|
||||
return True
|
||||
|
|
|
@ -18,8 +18,6 @@ import Utility.Metered
|
|||
import Annex.WorkTree
|
||||
import qualified Git
|
||||
import qualified Annex
|
||||
import Utility.Aeson
|
||||
import Messages.JSON (AddJSONActionItemField(..))
|
||||
|
||||
cmd :: Command
|
||||
cmd = withAnnexOptions [backendOption, jsonOptions] $
|
||||
|
@ -98,9 +96,7 @@ notAnnexed src a =
|
|||
|
||||
perform :: RawFilePath -> Key -> CommandPerform
|
||||
perform src key = do
|
||||
case toJSON' (AddJSONActionItemField "key" (serializeKey key)) of
|
||||
Object o -> maybeShowJSON $ AesonObject o
|
||||
_ -> noop
|
||||
maybeAddJSONField "key" (serializeKey key)
|
||||
ifM move
|
||||
( next $ cleanup key
|
||||
, giveup "failed"
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue