summaryrefslogtreecommitdiff
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
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.
-rw-r--r--Annex.hs2
-rw-r--r--Backend/SHA.hs3
-rw-r--r--Command/Unused.hs27
-rw-r--r--Options.hs3
-rw-r--r--debian/changelog5
-rw-r--r--doc/git-annex.mdwn6
6 files changed, 36 insertions, 10 deletions
diff --git a/Annex.hs b/Annex.hs
index 608151d82..f45415a72 100644
--- a/Annex.hs
+++ b/Annex.hs
@@ -40,6 +40,7 @@ data AnnexState = AnnexState
, repoqueue :: GitQueue.Queue
, quiet :: Bool
, force :: Bool
+ , fast :: Bool
, defaultbackend :: Maybe String
, defaultkey :: Maybe String
, toremote :: Maybe String
@@ -56,6 +57,7 @@ newState gitrepo allbackends = AnnexState
, repoqueue = GitQueue.empty
, quiet = False
, force = False
+ , fast = False
, defaultbackend = Nothing
, defaultkey = Nothing
, toremote = Nothing
diff --git a/Backend/SHA.hs b/Backend/SHA.hs
index 056385107..0ec555ce3 100644
--- a/Backend/SHA.hs
+++ b/Backend/SHA.hs
@@ -80,9 +80,10 @@ keyValue size file = do
checkKeyChecksum :: SHASize -> Key -> Annex Bool
checkKeyChecksum size key = do
g <- Annex.gitRepo
+ fast <- Annex.getState Annex.fast
let file = gitAnnexLocation g key
present <- liftIO $ doesFileExist file
- if not present
+ if (not present || fast)
then return True
else do
s <- shaN size file
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)
diff --git a/Options.hs b/Options.hs
index 4cd62c222..10c3714e4 100644
--- a/Options.hs
+++ b/Options.hs
@@ -22,6 +22,8 @@ commonOptions :: [Option]
commonOptions =
[ Option ['f'] ["force"] (NoArg (setforce True))
"allow actions that may lose annexed data"
+ , Option ['F'] ["fast"] (NoArg (setfast True))
+ "avoid slow operations"
, Option ['q'] ["quiet"] (NoArg (setquiet True))
"avoid verbose output"
, Option ['v'] ["verbose"] (NoArg (setquiet False))
@@ -31,5 +33,6 @@ commonOptions =
]
where
setforce v = Annex.changeState $ \s -> s { Annex.force = v }
+ setfast v = Annex.changeState $ \s -> s { Annex.fast = v }
setquiet v = Annex.changeState $ \s -> s { Annex.quiet = v }
setdefaultbackend v = Annex.changeState $ \s -> s { Annex.defaultbackend = Just v }
diff --git a/debian/changelog b/debian/changelog
index a5830884a..e0927817a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,11 @@ git-annex (0.20110321) UNRELEASED; urgency=low
with git-annex 0.24 or earlier.) The code is believed to work on
Linux, FreeBSD, and OSX; check compile-time messages to see if it
is not enabled for your OS.
+ * 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.
-- Joey Hess <joeyh@debian.org> Tue, 22 Mar 2011 16:52:00 -0400
diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn
index 1e4af022f..6168ebae2 100644
--- a/doc/git-annex.mdwn
+++ b/doc/git-annex.mdwn
@@ -278,6 +278,12 @@ Many git-annex commands will stage changes for later `git commit` by you.
Force unsafe actions, such as dropping a file's content when no other
source of it can be verified to still exist. Use with care.
+* --fast
+
+ Enables less expensive, but also less thorough versions of some commands.
+ What is avoided depends on the command. A fast fsck avoids calculating
+ checksums; a fast unused only shows temp files and not other unused files.
+
* --quiet
Avoid the default verbose logging of what is done; only show errors