summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-03-22 17:41:06 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-03-22 17:41:06 -0400
commitc21998722cb6a65993a3b72e66b225443cfce48b (patch)
treed09ad584739a119b5e74023bd735f2bc3085a1b2 /Command
parentaa2d8e33df3fc6ba204e28001ab0d1d231c9c58e (diff)
fast mode
Add --fast flag, that can enable less expensive, but also less thurough versions of some commands. * Add --fast flag, that can enable less expensive, but also less thurough versions of some commands. * fsck: In fast mode, avoid checking checksums. * unused: In fast mode, just show all existing temp files as unused, and avoid expensive scan for other unused content.
Diffstat (limited to 'Command')
-rw-r--r--Command/Unused.hs27
1 files changed, 18 insertions, 9 deletions
diff --git a/Command/Unused.hs b/Command/Unused.hs
index a1c4ee03c..518e98656 100644
--- a/Command/Unused.hs
+++ b/Command/Unused.hs
@@ -44,7 +44,6 @@ perform = do
checkUnused :: Annex Bool
checkUnused = do
- showNote "checking for unused data..."
(unused, staletmp) <- unusedKeys
let unusedlist = number 0 unused
let staletmplist = number (length unused) staletmp
@@ -81,17 +80,27 @@ number n (x:xs) = (n+1, x):(number (n+1) xs)
unusedKeys :: Annex ([Key], [Key])
unusedKeys = do
g <- Annex.gitRepo
- present <- getKeysPresent
- referenced <- getKeysReferenced
- tmps <- tmpKeys
- let (unused, staletmp, duptmp) = calcUnusedKeys present referenced tmps
+ fast <- Annex.getState Annex.fast
+ if fast
+ then do
+ showNote "fast mode enabled; assuming all temporary files are unused"
+ tmps <- tmpKeys
+ return ([], tmps)
+ else do
+ showNote "checking for unused data..."
+ present <- getKeysPresent
+ referenced <- getKeysReferenced
+ tmps <- tmpKeys
+
+ let (unused, staletmp, duptmp) = calcUnusedKeys present referenced tmps
- -- Tmp files that are dups of content already present can simply
- -- be removed.
- liftIO $ forM_ duptmp $ \t -> removeFile $ gitAnnexTmpLocation g t
+ -- Tmp files that are dups of content already present
+ -- can simply be removed.
+ liftIO $ forM_ duptmp $ \t -> removeFile $
+ gitAnnexTmpLocation g t
- return (unused, staletmp)
+ return (unused, staletmp)
calcUnusedKeys :: [Key] -> [Key] -> [Key] -> ([Key], [Key], [Key])
calcUnusedKeys present referenced tmps = (unused, staletmp, duptmp)