diff options
Diffstat (limited to 'Assistant/Threads/SanityChecker.hs')
-rw-r--r-- | Assistant/Threads/SanityChecker.hs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Assistant/Threads/SanityChecker.hs b/Assistant/Threads/SanityChecker.hs index b03298510..585a85cdf 100644 --- a/Assistant/Threads/SanityChecker.hs +++ b/Assistant/Threads/SanityChecker.hs @@ -25,8 +25,10 @@ import Utility.Batch import Utility.NotificationBroadcaster import Config import Utility.HumanTime +import Git.Repair import Data.Time.Clock.POSIX +import qualified Data.Set as S {- This thread runs once at startup, and most other threads wait for it - to finish. (However, the webapp thread does not, to prevent the UI @@ -36,6 +38,16 @@ sanityCheckerStartupThread startupdelay = namedThreadUnchecked "SanityCheckerSta {- Stale git locks can prevent commits from happening, etc. -} void $ repairStaleGitLocks =<< liftAnnex gitRepo + {- A corrupt index file can prevent the assistant from working at + - all, so detect and repair. -} + unlessM (liftAnnex $ inRepo $ checkIndex S.empty) $ do + debug ["corrupt index found at startup; removing"] + liftAnnex $ inRepo nukeIndex + {- Normally the startup scan avoids re-staging files, + - but with the index deleted, everything needs to be + - restaged. -} + modifyDaemonStatus_ $ \s -> s { forceRestage = True } + {- If there's a startup delay, it's done here. -} liftIO $ maybe noop (threadDelaySeconds . Seconds . fromIntegral . durationSeconds) startupdelay |