From 817ebb5765b7105a8f288581595f24e09417183c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 5 Apr 2018 14:44:58 -0400 Subject: [PATCH] info: Added "combined size of repositories containing these files" stat when run on a directory This commit was sponsored by andrea rota. --- CHANGELOG | 2 ++ Command/Info.hs | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 855c51c279..004bf899a6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,8 @@ git-annex (6.20180317) UNRELEASED; urgency=medium * Avoid running annex.http-headers-command more than once. * Enable HTTP connection reuse across multiple files, when git-annex uses http-conduit. + * info: Added "combined size of repositories containing these files" + stat when run on a directory. -- Joey Hess Mon, 19 Mar 2018 23:13:59 -0400 diff --git a/Command/Info.hs b/Command/Info.hs index 394e27605e..54e067a80b 100644 --- a/Command/Info.hs +++ b/Command/Info.hs @@ -56,6 +56,15 @@ data KeyData = KeyData , backendsKeys :: M.Map KeyVariety Integer } +instance Monoid KeyData where + mempty = KeyData 0 0 0 M.empty + mappend a b = KeyData + { countKeys = countKeys a + countKeys b + , sizeKeys = sizeKeys a + sizeKeys b + , unknownSizeKeys = unknownSizeKeys a + unknownSizeKeys b + , backendsKeys = backendsKeys a <> backendsKeys b + } + data NumCopiesStats = NumCopiesStats { numCopiesVarianceMap :: M.Map Variance Integer } @@ -237,6 +246,7 @@ tree_slow_stats :: [FilePath -> Stat] tree_slow_stats = [ const numcopies_stats , const reposizes_stats + , const reposizes_total ] file_stats :: FilePath -> Key -> [Stat] @@ -492,6 +502,10 @@ reposizes_stats = stat desc $ nojson $ do } lpad n s = (replicate (n - length s) ' ') ++ s +reposizes_total :: Stat +reposizes_total = simpleStat "combined size of repositories containing these files" $ + showSizeKeys . mconcat . M.elems =<< cachedRepoData + cachedPresentData :: StatState KeyData cachedPresentData = do s <- get