aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-10-23 14:43:58 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-10-23 14:43:58 -0400
commitdcca572a4d95b5bf926468c30e8a01413b665323 (patch)
tree3547aa46bb7eba9b804a2c508ff2daef5cffdc49
parent9ed8dd6be036e79e3ec7f5781b9f7b8864e1bc0e (diff)
wire git repair into webapp
-rw-r--r--Command/Repair.hs3
-rw-r--r--Git/Repair.hs30
2 files changed, 17 insertions, 16 deletions
diff --git a/Command/Repair.hs b/Command/Repair.hs
index 8808ef9de..6b1b5df4a 100644
--- a/Command/Repair.hs
+++ b/Command/Repair.hs
@@ -29,8 +29,7 @@ runRepair :: Bool -> Annex Bool
runRepair forced = do
(ok, stillmissing, modifiedbranches) <- inRepo $
Git.Repair.runRepair forced
- when ok $
- repairAnnexBranch stillmissing modifiedbranches
+ repairAnnexBranch stillmissing modifiedbranches
return ok
{- After git repository repair, the .git/annex/index file could
diff --git a/Git/Repair.hs b/Git/Repair.hs
index cc54e49dc..984378bbb 100644
--- a/Git/Repair.hs
+++ b/Git/Repair.hs
@@ -7,6 +7,7 @@
module Git.Repair (
runRepair,
+ runRepairOf,
cleanCorruptObjects,
retrieveMissingObjects,
resetLocalBranches,
@@ -426,24 +427,25 @@ runRepair forced g = do
putStrLn "Running git fsck ..."
fsckresult <- findBroken False g
if foundBroken fsckresult
- then makerepairs fsckresult
+ then runRepairOf fsckresult forced g
else do
putStrLn "No problems found."
return (True, S.empty, [])
+runRepairOf :: FsckResults -> Bool -> Repo -> IO (Bool, MissingObjects, [Branch])
+runRepairOf fsckresult forced g = do
+ missing <- cleanCorruptObjects fsckresult g
+ stillmissing <- retrieveMissingObjects missing g
+ if S.null stillmissing
+ then successfulfinish stillmissing []
+ else do
+ putStrLn $ unwords
+ [ show (S.size stillmissing)
+ , "missing objects could not be recovered!"
+ ]
+ if forced
+ then continuerepairs stillmissing
+ else unsuccessfulfinish stillmissing
where
- makerepairs fsckresult = do
- missing <- cleanCorruptObjects fsckresult g
- stillmissing <- retrieveMissingObjects missing g
- if S.null stillmissing
- then successfulfinish stillmissing []
- else do
- putStrLn $ unwords
- [ show (S.size stillmissing)
- , "missing objects could not be recovered!"
- ]
- if forced
- then continuerepairs stillmissing
- else unsuccessfulfinish stillmissing
continuerepairs stillmissing = do
(remotebranches, goodcommits) <- removeTrackingBranches stillmissing emptyGoodCommits g
unless (null remotebranches) $