Merge branch 'master' of ssh://git-annex.branchable.com
This commit is contained in:
commit
1f1ac8b838
1 changed files with 14 additions and 29 deletions
|
@ -45,35 +45,18 @@ import qualified Data.ByteString.Lazy as L
|
||||||
import Data.Tuple.Utils
|
import Data.Tuple.Utils
|
||||||
|
|
||||||
{- Given a set of bad objects found by git fsck, which may not
|
{- Given a set of bad objects found by git fsck, which may not
|
||||||
- be complete, finds and removes all corrupt objects,
|
- be complete, finds and removes all corrupt objects. -}
|
||||||
- and returns missing objects.
|
cleanCorruptObjects :: FsckResults -> Repo -> IO ()
|
||||||
-}
|
|
||||||
cleanCorruptObjects :: FsckResults -> Repo -> IO FsckResults
|
|
||||||
cleanCorruptObjects fsckresults r = do
|
cleanCorruptObjects fsckresults r = do
|
||||||
void $ explodePacks r
|
void $ explodePacks r
|
||||||
objs <- listLooseObjectShas r
|
mapM_ removeLoose (S.toList $ knownMissing fsckresults)
|
||||||
mapM_ (tryIO . allowRead . looseObjectFile r) objs
|
mapM_ removeBad =<< listLooseObjectShas r
|
||||||
bad <- findMissing objs r
|
where
|
||||||
void $ removeLoose r $ S.union bad (knownMissing fsckresults)
|
removeLoose s = nukeFile (looseObjectFile r s)
|
||||||
-- Rather than returning the loose objects that were removed, re-run
|
removeBad s = do
|
||||||
-- fsck. Other missing objects may have been in the packs,
|
void $ tryIO $ allowRead $ looseObjectFile r s
|
||||||
-- and this way fsck will find them.
|
whenM (isMissing s r) $
|
||||||
findBroken False r
|
removeLoose s
|
||||||
|
|
||||||
removeLoose :: Repo -> MissingObjects -> IO Bool
|
|
||||||
removeLoose r s = do
|
|
||||||
fs <- filterM doesFileExist (map (looseObjectFile r) (S.toList s))
|
|
||||||
let count = length fs
|
|
||||||
if count > 0
|
|
||||||
then do
|
|
||||||
putStrLn $ unwords
|
|
||||||
[ "Removing"
|
|
||||||
, show count
|
|
||||||
, "corrupt loose objects."
|
|
||||||
]
|
|
||||||
mapM_ nukeFile fs
|
|
||||||
return True
|
|
||||||
else return False
|
|
||||||
|
|
||||||
{- Explodes all pack files, and deletes them.
|
{- Explodes all pack files, and deletes them.
|
||||||
-
|
-
|
||||||
|
@ -465,7 +448,8 @@ runRepairOf fsckresult removablebranch forced referencerepo g = do
|
||||||
|
|
||||||
runRepair' :: (Ref -> Bool) -> FsckResults -> Bool -> Maybe FilePath -> Repo -> IO (Bool, [Branch])
|
runRepair' :: (Ref -> Bool) -> FsckResults -> Bool -> Maybe FilePath -> Repo -> IO (Bool, [Branch])
|
||||||
runRepair' removablebranch fsckresult forced referencerepo g = do
|
runRepair' removablebranch fsckresult forced referencerepo g = do
|
||||||
missing <- cleanCorruptObjects fsckresult g
|
cleanCorruptObjects fsckresult g
|
||||||
|
missing <- findBroken False g
|
||||||
stillmissing <- retrieveMissingObjects missing referencerepo g
|
stillmissing <- retrieveMissingObjects missing referencerepo g
|
||||||
case stillmissing of
|
case stillmissing of
|
||||||
FsckFoundMissing s
|
FsckFoundMissing s
|
||||||
|
@ -493,7 +477,8 @@ runRepair' removablebranch fsckresult forced referencerepo g = do
|
||||||
FsckFailed
|
FsckFailed
|
||||||
| forced -> ifM (pure (repoIsLocalBare g) <||> checkIndex g)
|
| forced -> ifM (pure (repoIsLocalBare g) <||> checkIndex g)
|
||||||
( do
|
( do
|
||||||
missing' <- cleanCorruptObjects FsckFailed g
|
cleanCorruptObjects FsckFailed g
|
||||||
|
missing' <- findBroken False g
|
||||||
case missing' of
|
case missing' of
|
||||||
FsckFailed -> return (False, [])
|
FsckFailed -> return (False, [])
|
||||||
FsckFoundMissing stillmissing' ->
|
FsckFoundMissing stillmissing' ->
|
||||||
|
|
Loading…
Add table
Reference in a new issue