update RepoSize database from git-annex branch incrementally

The use of catObjectStream is optimally fast. Although it might be
possible to combine this with git-annex branch merge to avoid some
redundant work.

Benchmarking, a git-annex branch that had 100000 files changed
took less than 1.88 seconds to run through this.
This commit is contained in:
Joey Hess 2024-08-17 13:30:24 -04:00
parent 8239824d92
commit d09a005f2b
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
9 changed files with 115 additions and 33 deletions

View file

@ -5,7 +5,7 @@
- Licensed under the GNU AGPL version 3 or higher.
-}
{-# LANGUAGE OverloadedStrings, ScopedTypeVariables, CPP #-}
{-# LANGUAGE OverloadedStrings, ScopedTypeVariables, BangPatterns, CPP #-}
module Messages (
showStartMessage,
@ -54,6 +54,7 @@ module Messages (
prompt,
mkPrompter,
sanitizeTopLevelExceptionMessages,
countdownToMessage,
) where
import Control.Concurrent
@ -364,3 +365,17 @@ sanitizeTopLevelExceptionMessages a = a `catches`
go e = do
hPutStrLn stderr $ safeOutput $ toplevelMsg (show e)
exitWith $ ExitFailure 1
{- Used to only run an action that displays a message after the specified
- number of steps. This is useful when performing an action that can
- sometimes take a long time, but often does not.
-}
countdownToMessage :: Int -> Annex () -> Annex Int
countdownToMessage n showmsg
| n < 1 = return 0
| n == 1 = do
showmsg
return 0
| otherwise = do
let !n' = pred n
return n'