fsck: Print warnings to stderr; --quiet can now be used to only see problems.

This commit is contained in:
Joey Hess 2010-11-15 18:37:49 -04:00
parent a5e7f5329f
commit 0893820812
7 changed files with 16 additions and 14 deletions

View file

@ -175,12 +175,12 @@ checkKeyNumCopies key = do
let present = length remotes + if inannex then 1 else 0 let present = length remotes + if inannex then 1 else 0
if (present < needed) if (present < needed)
then do then do
showLongNote $ note present needed warning $ note present needed
return False return False
else return True else return True
where where
note 0 _ = "** No known copies of the file exist!" note 0 _ = "** No known copies of the file exist!"
note present needed = note present needed =
"Only " ++ show present ++ " of " ++ show needed ++ "Only " ++ show present ++ " of " ++ show needed ++
" copies exist. " ++ " copies of "++show key++" exist. " ++
"Run git annex get somewhere else to back it up." "Run git annex get somewhere else to back it up."

View file

@ -57,5 +57,5 @@ checkKeySHA1 key = do
then return True then return True
else do else do
dest <- moveBad key dest <- moveBad key
showLongNote $ "Bad file content; moved to "++dest warning $ "Bad file content; moved to "++dest
return False return False

View file

@ -66,5 +66,5 @@ checkKeySize key = do
then return True then return True
else do else do
dest <- moveBad key dest <- moveBad key
showLongNote $ "Bad file size; moved to "++dest warning $ "Bad file size; moved to "++dest
return False return False

View file

@ -28,10 +28,8 @@ start = do
perform :: SubCmdPerform perform :: SubCmdPerform
perform = do perform = do
ok <- checkUnused _ <- checkUnused
if ok return $ Just $ return True
then return $ Just $ return True
else return Nothing
checkUnused :: Annex Bool checkUnused :: Annex Bool
checkUnused = do checkUnused = do

View file

@ -54,4 +54,6 @@ showErr :: (Show a) => a -> Annex ()
showErr e = warning $ show e showErr e = warning $ show e
warning :: String -> Annex () warning :: String -> Annex ()
warning s = liftIO $ hPutStrLn stderr $ "git-annex: " ++ s warning s = do
verbose $ liftIO $ putStr "\n"
liftIO $ hPutStrLn stderr $ "git-annex: " ++ s

2
debian/changelog vendored
View file

@ -4,6 +4,8 @@ git-annex (0.07) UNRELEASED; urgency=low
* unused: New subcommand, finds unused data. (Split out from fsck.) * unused: New subcommand, finds unused data. (Split out from fsck.)
* dropunused: New subcommand, provides for easy dropping of unused keys * dropunused: New subcommand, provides for easy dropping of unused keys
by number, as listed by the unused subcommand. by number, as listed by the unused subcommand.
* fsck: Print warnings to stderr; --quiet can now be used to only see
problems.
-- Joey Hess <joeyh@debian.org> Sun, 14 Nov 2010 12:34:49 -0400 -- Joey Hess <joeyh@debian.org> Sun, 14 Nov 2010 12:34:49 -0400

View file

@ -296,7 +296,7 @@ eliminate it to save space.
2 WORM:1289672605:14:file 2 WORM:1289672605:14:file
(To see where data was previously used, try: git log --stat -S'KEY') (To see where data was previously used, try: git log --stat -S'KEY')
(To remove unwanted data: git-annex dropunused NUMBER) (To remove unwanted data: git-annex dropunused NUMBER)
failed ok
After running `git annex unused`, you can follow the instructions to examine After running `git annex unused`, you can follow the instructions to examine
the history of files that used the data, and if you decide you don't need that the history of files that used the data, and if you decide you don't need that
@ -316,7 +316,7 @@ setting is satisfied for all files.
# git annex fsck # git annex fsck
unused (checking for unused data...) ok unused (checking for unused data...) ok
fsck my_cool_big_file (checksum...) ok fsck my_cool_big_file (checksum...) ok
...... ...
You can also specifiy the files to check. This is particularly useful if You can also specifiy the files to check. This is particularly useful if
you're using sha1 and don't want to spend a long time checksumming everything. you're using sha1 and don't want to spend a long time checksumming everything.
@ -332,10 +332,10 @@ might say about a badly messed up annex:
# git annex fsck # git annex fsck
fsck my_cool_big_file (checksum...) fsck my_cool_big_file (checksum...)
Bad file content; moved to .git/annex/bad/SHA1:7da006579dd64330eb2456001fd01948430572f2 git-annex: Bad file content; moved to .git/annex/bad/SHA1:7da006579dd64330eb2456001fd01948430572f2
** No known copies of the file exist! git-annex: ** No known copies of the file exist!
failed failed
fsck important_file fsck important_file
Only 1 of 2 copies exist. Run git annex get somewhere else to back it up. git-annex: Only 1 of 2 copies exist. Run git annex get somewhere else to back it up.
failed failed
git-annex: 2 failed git-annex: 2 failed