better handling of missing index file
This commit is contained in:
parent
188e4c00c1
commit
eab4470440
2 changed files with 25 additions and 18 deletions
|
@ -40,13 +40,18 @@ sanityCheckerStartupThread startupdelay = namedThreadUnchecked "SanityCheckerSta
|
||||||
|
|
||||||
{- A corrupt index file can prevent the assistant from working at
|
{- A corrupt index file can prevent the assistant from working at
|
||||||
- all, so detect and repair. -}
|
- all, so detect and repair. -}
|
||||||
unlessM (liftAnnex $ inRepo $ checkIndex S.empty) $ do
|
ifM (liftAnnex $ inRepo $ checkIndex S.empty)
|
||||||
debug ["corrupt index found at startup; removing"]
|
( do
|
||||||
liftAnnex $ inRepo nukeIndex
|
debug ["corrupt index file found at startup; removing and restaging"]
|
||||||
{- Normally the startup scan avoids re-staging files,
|
liftAnnex $ inRepo nukeIndex
|
||||||
- but with the index deleted, everything needs to be
|
{- Normally the startup scan avoids re-staging files,
|
||||||
- restaged. -}
|
- but with the index deleted, everything needs to be
|
||||||
modifyDaemonStatus_ $ \s -> s { forceRestage = True }
|
- 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. -}
|
{- If there's a startup delay, it's done here. -}
|
||||||
liftIO $ maybe noop (threadDelaySeconds . Seconds . fromIntegral . durationSeconds) startupdelay
|
liftIO $ maybe noop (threadDelaySeconds . Seconds . fromIntegral . durationSeconds) startupdelay
|
||||||
|
|
|
@ -13,6 +13,7 @@ module Git.Repair (
|
||||||
resetLocalBranches,
|
resetLocalBranches,
|
||||||
removeTrackingBranches,
|
removeTrackingBranches,
|
||||||
checkIndex,
|
checkIndex,
|
||||||
|
missingIndex,
|
||||||
nukeIndex,
|
nukeIndex,
|
||||||
emptyGoodCommits,
|
emptyGoodCommits,
|
||||||
) where
|
) where
|
||||||
|
@ -369,18 +370,19 @@ verifyTree missing treesha r
|
||||||
else cleanup
|
else cleanup
|
||||||
|
|
||||||
{- Checks that the index file only refers to objects that are not missing,
|
{- Checks that the index file only refers to objects that are not missing,
|
||||||
- and is not itself corrupt or missing. -}
|
- and is not itself corrupt. Note that a missing index file is not
|
||||||
|
- considered a problem (repo may be new). -}
|
||||||
checkIndex :: MissingObjects -> Repo -> IO Bool
|
checkIndex :: MissingObjects -> Repo -> IO Bool
|
||||||
checkIndex missing r = ifM (doesFileExist (localGitDir r </> "index"))
|
checkIndex missing r = do
|
||||||
( do
|
(bad, _good, cleanup) <- partitionIndex missing r
|
||||||
(bad, _good, cleanup) <- partitionIndex missing r
|
if null bad
|
||||||
if null bad
|
then cleanup
|
||||||
then cleanup
|
else do
|
||||||
else do
|
void cleanup
|
||||||
void cleanup
|
return False
|
||||||
return False
|
|
||||||
, return False
|
missingIndex :: Repo -> IO Bool
|
||||||
)
|
missingIndex r = not <$> doesFileExist (localGitDir r </> "index")
|
||||||
|
|
||||||
partitionIndex :: MissingObjects -> Repo -> IO ([LsFiles.StagedDetails], [LsFiles.StagedDetails], IO Bool)
|
partitionIndex :: MissingObjects -> Repo -> IO ([LsFiles.StagedDetails], [LsFiles.StagedDetails], IO Bool)
|
||||||
partitionIndex missing r = do
|
partitionIndex missing r = do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue