better handling of missing index file

This commit is contained in:
Joey Hess 2013-11-13 14:39:26 -04:00
parent 188e4c00c1
commit eab4470440
2 changed files with 25 additions and 18 deletions

View file

@ -40,13 +40,18 @@ sanityCheckerStartupThread startupdelay = namedThreadUnchecked "SanityCheckerSta
{- 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 }
ifM (liftAnnex $ inRepo $ checkIndex S.empty)
( do
debug ["corrupt index file found at startup; removing and restaging"]
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 }
, whenM (liftAnnex $ inRepo missingIndex) $ do
debug ["no index file; restaging"]
modifyDaemonStatus_ $ \s -> s { forceRestage = True }
)
{- If there's a startup delay, it's done here. -}
liftIO $ maybe noop (threadDelaySeconds . Seconds . fromIntegral . durationSeconds) startupdelay