summaryrefslogtreecommitdiff
path: root/Upgrade
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 /Upgrade
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 'Upgrade')
-rw-r--r--Upgrade/V1.hs25
1 files changed, 13 insertions, 12 deletions
diff --git a/Upgrade/V1.hs b/Upgrade/V1.hs
index 1bf3cc0e8..64ca298eb 100644
--- a/Upgrade/V1.hs
+++ b/Upgrade/V1.hs
@@ -66,9 +66,10 @@ upgrade = do
updateSymlinks
moveLocationLogs
+ Annex.queueRun
+
-- add new line to auto-merge hashed location logs
-- this commits, so has to come after the upgrade
- g <- Annex.gitRepo
liftIO $ Command.Init.gitAttributesWrite g
setVersion
@@ -92,18 +93,18 @@ updateSymlinks :: Annex ()
updateSymlinks = do
g <- Annex.gitRepo
files <- liftIO $ Git.inRepo g [Git.workTree g]
- forM_ files $ (fixlink g)
+ forM_ files $ fixlink
where
- fixlink g f = do
+ fixlink f = do
r <- lookupFile1 f
case r of
Nothing -> return ()
Just (k, _) -> do
link <- calcGitLink f k
- liftIO $ do
- removeFile f
- createSymbolicLink link f
- Git.run g "add" [Param "--", File f]
+ liftIO $ removeFile f
+ liftIO $ createSymbolicLink link f
+ Annex.queue "add" [Param "--"] f
+ Annex.queueRunAt 1024
moveLocationLogs :: Annex ()
moveLocationLogs = do
@@ -127,11 +128,11 @@ moveLocationLogs = do
-- logs that have been pulled from elsewhere
old <- liftIO $ readLog f
new <- liftIO $ readLog dest
- liftIO $ do
- writeLog dest (old++new)
- Git.run g "add" [Param "--", File dest]
- Git.run g "add" [Param "--", File f]
- Git.run g "rm" [Param "--quiet", Param "-f", Param "--", File f]
+ liftIO $ writeLog dest (old++new)
+ Annex.queue "add" [Param "--"] dest
+ Annex.queue "add" [Param "--"] f
+ Annex.queue "rm" [Param "--quiet", Param "-f", Param "--"] f
+ Annex.queueRunAt 1024
oldlog2key :: FilePath -> Maybe (FilePath, Key)
oldlog2key l =