From 5d8b8a8ad0b7f213cb38242daa667b5a4bfa252d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 13 Nov 2023 13:15:07 -0400 Subject: [PATCH] git-annex log --totalsizes Note that dead repositories are not yet handled so their sizes show as nonzero after they are marked dead. Sponsored-By: unqueued on Patreon --- Command/Log.hs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Command/Log.hs b/Command/Log.hs index 0a86c8ad5e..da521b43a9 100644 --- a/Command/Log.hs +++ b/Command/Log.hs @@ -46,6 +46,7 @@ data LogOptions = LogOptions , allOption :: Bool , sizesOfOption :: Maybe (DeferredParse UUID) , sizesOption :: Bool + , totalSizesOption :: Bool , whenOption :: Maybe Duration , rawDateOption :: Bool , bytesOption :: Bool @@ -71,6 +72,10 @@ optParser desc = LogOptions ( long "sizes" <> help "display history of sizes of all repositories" ) + <*> switch + ( long "totalsizes" + <> help "display history of total sizes of all repositories" + ) <*> optional (option (eitherReader parseDuration) ( long "when" <> metavar paramTime <> help "when to display changed size" @@ -108,7 +113,7 @@ seek :: LogOptions -> CommandSeek seek o = ifM (null <$> Annex.Branch.getUnmergedRefs) ( maybe (pure Nothing) (Just <$$> getParsed) (sizesOfOption o) >>= \case Just u -> sizeHistoryInfo (Just u) o - Nothing -> if sizesOption o + Nothing -> if sizesOption o || totalSizesOption o then sizeHistoryInfo Nothing o else go , giveup "This repository is read-only, and there are unmerged git-annex branches, which prevents displaying location log changes. (Set annex.merge-annex-branches to false to ignore the unmerged git-annex branches.)" @@ -405,7 +410,9 @@ sizeHistoryInfo mu o = do us = case mu of Just u -> [u] Nothing -> M.keys uuidmap - sizes = map (\u -> fromMaybe 0 (M.lookup u sizemap)) us + sizes + | totalSizesOption o = [sum (M.elems sizemap)] + | otherwise = map (\u -> fromMaybe 0 (M.lookup u sizemap)) us dt = maybe 1 durationToPOSIXTime (whenOption o) displayts zone t output = putStrLn $ ts ++ "," ++ output