From 121659576b7f7005e36086e21d8d2daa04294ff6 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 1 Jan 2016 16:33:05 -0400 Subject: [PATCH] info --json: Improve json for "backend usage", using a nested object with fields for each backend instead of the previous weird nested lists. This may break existing parsers of this json output, if there were any. --- Command/Info.hs | 5 ++-- debian/changelog | 3 +++ ..._5db5f19d9bdc81839d984b7e302e49ed._comment | 23 +++++++++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 doc/bugs/info_--json_lists_backend_usage_stats_as_a_list_of_lists/comment_1_5db5f19d9bdc81839d984b7e302e49ed._comment diff --git a/Command/Info.hs b/Command/Info.hs index 763279612b..cb55602a6a 100644 --- a/Command/Info.hs +++ b/Command/Info.hs @@ -12,7 +12,6 @@ module Command.Info where import "mtl" Control.Monad.State.Strict import qualified Data.Map.Strict as M import Text.JSON -import Data.Tuple import Data.Ord import Common.Annex @@ -403,9 +402,9 @@ disk_size = simpleStat "available local disk space" $ backend_usage :: Stat backend_usage = stat "backend usage" $ json fmt $ - sort . M.toList . backendsKeys <$> cachedReferencedData + toJSObject . sort . M.toList . backendsKeys <$> cachedReferencedData where - fmt = multiLine . map (\(n, b) -> b ++ ": " ++ show n) . map swap + fmt = multiLine . map (\(b, n) -> b ++ ": " ++ show n) . fromJSObject numcopies_stats :: Stat numcopies_stats = stat "numcopies stats" $ json fmt $ diff --git a/debian/changelog b/debian/changelog index 0563eba435..22db45245c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -35,6 +35,9 @@ git-annex (6.20151219) UNRELEASED; urgency=medium there. * info: Fix "backend usage" numbers, which were counting present keys twice. + * info --json: Improve json for "backend usage", using a nested object + with fields for each backend instead of the previous weird nested lists. + This may break existing parsers of this json output, if there were any. -- Joey Hess Sat, 19 Dec 2015 13:31:17 -0400 diff --git a/doc/bugs/info_--json_lists_backend_usage_stats_as_a_list_of_lists/comment_1_5db5f19d9bdc81839d984b7e302e49ed._comment b/doc/bugs/info_--json_lists_backend_usage_stats_as_a_list_of_lists/comment_1_5db5f19d9bdc81839d984b7e302e49ed._comment new file mode 100644 index 0000000000..81a999e20e --- /dev/null +++ b/doc/bugs/info_--json_lists_backend_usage_stats_as_a_list_of_lists/comment_1_5db5f19d9bdc81839d984b7e302e49ed._comment @@ -0,0 +1,23 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 1""" + date="2016-01-01T20:27:27Z" + content=""" +It was indeed a bug that it counted both keys referenced in the work tree +and keys whose content was present. Fixed. + +It's not hard to fix the json format, but then what happens to anything +that may be parsing the existing format? I could use a different field +for the better formatted version and keep the old version in the current +field, but if the goal is to make the json better, that doesn't really +work. + +Since the old output is so funky, it seems likely to me you're the first +one to try to consume it since anyone reasonable would file a but report +about it and you're the first who did. + +So.. I guess I'll change the json format and see if anyone complains. + +I have to say that this business of not having any specification other +than what it currently is, is what annoys me about JSON as a consumer of it. +"""]]