assistant: Automatically repair damanged git repository, if it can be done without losing data.

This commit is contained in:
Joey Hess 2013-10-26 17:16:29 -04:00
parent a1b1b5ef52
commit b48aaa22d0
4 changed files with 49 additions and 18 deletions

View file

@ -33,7 +33,7 @@ import Assistant.WebApp.Types
#endif
import Git.Remote (RemoteName)
import qualified Git.Fsck
import Logs.FsckResults
import Assistant.Repair
import Control.Concurrent.Async
import Control.Concurrent.MVar
@ -189,12 +189,9 @@ runActivity' urlrenderer (ScheduledSelfFsck _ d) = do
r <- Git.Fsck.findBroken True g
void $ batchCommand program (Param "fsck" : annexFsckParams d)
return r
when (Git.Fsck.foundBroken fsckresults) $ do
u <- liftAnnex getUUID
liftAnnex $ writeFsckResults u fsckresults
button <- mkAlertButton True (T.pack "Click Here") urlrenderer $
RepairRepositoryR u
void $ addAlert $ brokenRepositoryAlert button
when (Git.Fsck.foundBroken fsckresults) $
brokenRepositoryDetected fsckresults urlrenderer
=<< liftAnnex getUUID
mapM_ reget =<< liftAnnex (dirKeys gitAnnexBadDir)
where
reget k = queueTransfers "fsck found bad file; redownloading" Next k Nothing Download