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.
This commit is contained in:
parent
aa2d8e33df
commit
c21998722c
6 changed files with 36 additions and 10 deletions
2
Annex.hs
2
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
-- Tmp files that are dups of content already present can simply
|
||||
-- be removed.
|
||||
liftIO $ forM_ duptmp $ \t -> removeFile $ gitAnnexTmpLocation g t
|
||||
let (unused, staletmp, duptmp) = calcUnusedKeys present referenced tmps
|
||||
|
||||
return (unused, staletmp)
|
||||
-- Tmp files that are dups of content already present
|
||||
-- can simply be removed.
|
||||
liftIO $ forM_ duptmp $ \t -> removeFile $
|
||||
gitAnnexTmpLocation g t
|
||||
|
||||
return (unused, staletmp)
|
||||
|
||||
calcUnusedKeys :: [Key] -> [Key] -> [Key] -> ([Key], [Key], [Key])
|
||||
calcUnusedKeys present referenced tmps = (unused, staletmp, duptmp)
|
||||
|
|
|
@ -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 }
|
||||
|
|
5
debian/changelog
vendored
5
debian/changelog
vendored
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue