summaryrefslogtreecommitdiff
path: root/Command/MetaData.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2016-07-26 19:50:02 -0400
committerJoey Hess <joeyh@joeyh.name>2016-07-26 19:50:02 -0400
commit928fbb162df0099eb5b75385e6bda926277f48ce (patch)
tree080cf60051720a35fbe5a268628c8e6b5e58fc38 /Command/MetaData.hs
parent870873bdaa5e9e1e8838f484c9b6c7068f4e334c (diff)
improved use of Aeson for JSONActionItem
Diffstat (limited to 'Command/MetaData.hs')
-rw-r--r--Command/MetaData.hs13
1 files changed, 9 insertions, 4 deletions
diff --git a/Command/MetaData.hs b/Command/MetaData.hs
index 66469f2fc9..d33372d0b0 100644
--- a/Command/MetaData.hs
+++ b/Command/MetaData.hs
@@ -10,7 +10,7 @@ module Command.MetaData where
import Command
import Annex.MetaData
import Logs.MetaData
-import Messages.JSON (ParsedJSON(..))
+import Messages.JSON (JSONActionItem(..))
import qualified Data.Set as S
import qualified Data.Text as T
@@ -131,6 +131,11 @@ fieldsField = T.pack "fields"
parseJSONInput :: String -> Maybe (Either FilePath Key, MetaData)
parseJSONInput i = do
v <- decode (BU.fromString i)
- case parsedAdded v of
- Nothing -> return (parsedKeyfile v, emptyMetaData)
- Just (MetaDataFields m) -> return (parsedKeyfile v, m)
+ let m = case itemAdded v of
+ Nothing -> emptyMetaData
+ Just (MetaDataFields m') -> m'
+ let keyfile = case (itemKey v, itemFile v) of
+ (Just k, _) -> Right k
+ (Nothing, Just f) -> Left f
+ (Nothing, Nothing) -> error "JSON input is missing either file or key"
+ return (keyfile, m)