summaryrefslogtreecommitdiff
path: root/Assistant/Threads
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-01-14 17:10:30 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-01-14 17:10:30 -0400
commit985e3aebbef10d3bf2a0d9625747a19a793aecd1 (patch)
tree2cc475421a3342f41e5712656bef979750e8ad7b /Assistant/Threads
parentc340ae26370b4b3eca5433fd2462836abce19533 (diff)
assistant: Detect if .git/annex/index is corrupt at startup, and recover.
Diffstat (limited to 'Assistant/Threads')
-rw-r--r--Assistant/Threads/SanityChecker.hs7
1 files changed, 7 insertions, 0 deletions
diff --git a/Assistant/Threads/SanityChecker.hs b/Assistant/Threads/SanityChecker.hs
index 446ade54f..8aa691cdc 100644
--- a/Assistant/Threads/SanityChecker.hs
+++ b/Assistant/Threads/SanityChecker.hs
@@ -16,6 +16,7 @@ import Assistant.DaemonStatus
import Assistant.Alert
import Assistant.Repair
import Assistant.Ssh
+import qualified Annex.Branch
import qualified Git.LsFiles
import qualified Git.Command
import qualified Git.Config
@@ -53,6 +54,12 @@ sanityCheckerStartupThread startupdelay = namedThreadUnchecked "SanityCheckerSta
debug ["no index file; restaging"]
modifyDaemonStatus_ $ \s -> s { forceRestage = True }
)
+ {- If the git-annex index file is corrupt, it's ok to remove it;
+ - the data from the git-annex branch will be used, and the index
+ - will be automatically regenerated. -}
+ unlessM (liftAnnex $ Annex.Branch.withIndex $ inRepo $ Git.Repair.checkIndexFast) $ do
+ notice ["corrupt annex/index file found at startup; removing"]
+ liftAnnex $ liftIO . nukeFile =<< fromRepo gitAnnexIndex
{- Fix up ssh remotes set up by past versions of the assistant. -}
liftIO $ fixUpSshRemotes