summaryrefslogtreecommitdiff
path: root/Annex.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-03-16 15:10:15 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-03-16 15:10:15 -0400
commitbc21502b9a640e798dc6bbbb255aa9742a1c6187 (patch)
treef334f7a1dedba0a68b0549e2e44b3278bcac3d44 /Annex.hs
parent0f8edc99ee76a80c948bdedc42730e7679a822a0 (diff)
use queue when upgrading, flushing every so often
Added a cheap way to query the size of a queue. runQueueAt is not the default yet only because there may be some code that expects to be able to queue some suff, do something else, and run the whole queue at the end. 10240 is an arbitrary size for the queue. If we assume annexed filenames are between 10 and 255 characters long, then the queue will build up between 100kb and 2550kb long commands. The max command line length on linux is somewhere above 20k, so this is a fairly good balance -- the queue will buffer only a few megabytes of stuff and a minimal number of commands will be run by xargs. Also, insert queue items strictly, this should save memory.
Diffstat (limited to 'Annex.hs')
-rw-r--r--Annex.hs8
1 files changed, 8 insertions, 0 deletions
diff --git a/Annex.hs b/Annex.hs
index f8cfd0ec9..608151d82 100644
--- a/Annex.hs
+++ b/Annex.hs
@@ -16,6 +16,7 @@ module Annex (
gitRepo,
queue,
queueRun,
+ queueRunAt,
setConfig,
repoConfig
) where
@@ -109,6 +110,13 @@ queueRun = do
liftIO $ GitQueue.run g q
put state { repoqueue = GitQueue.empty }
+{- Runs the queue if the specified number of items have been queued. -}
+queueRunAt :: Integer -> Annex ()
+queueRunAt n = do
+ state <- get
+ let q = repoqueue state
+ when (GitQueue.size q >= n) queueRun
+
{- Changes a git config setting in both internal state and .git/config -}
setConfig :: String -> String -> Annex ()
setConfig k value = do