fix stale git locks as part of repo repair
This commit is contained in:
parent
fabb0c50b7
commit
791c8535b5
3 changed files with 12 additions and 9 deletions
|
@ -119,15 +119,16 @@ runRepair u mrmt destructiverepair = do
|
|||
- least work to detect is another machine is writing out a new index
|
||||
- file, since git does so by writing the new content to index.lock.
|
||||
-}
|
||||
checkStaleGitLocks :: Assistant ()
|
||||
checkStaleGitLocks = do
|
||||
repairStaleGitLocks :: Git.Repo -> Assistant ()
|
||||
repairStaleGitLocks r = do
|
||||
lockfiles <- filter (not . isInfixOf "gc.pid")
|
||||
. filter (".lock" `isSuffixOf`)
|
||||
<$> (liftIO . dirContentsRecursiveSkipping (== dropTrailingPathSeparator annexDir)
|
||||
=<< liftAnnex (fromRepo Git.localGitDir))
|
||||
checkStaleLocks lockfiles
|
||||
checkStaleLocks :: [FilePath] -> Assistant ()
|
||||
checkStaleLocks lockfiles = go =<< getsizes
|
||||
<$> liftIO (findgitfiles r)
|
||||
repairStaleLocks lockfiles
|
||||
where
|
||||
findgitfiles = dirContentsRecursiveSkipping (== dropTrailingPathSeparator annexDir) . Git.localGitDir
|
||||
repairStaleLocks :: [FilePath] -> Assistant ()
|
||||
repairStaleLocks lockfiles = go =<< getsizes
|
||||
where
|
||||
getsize lf = catchMaybeIO $
|
||||
(\s -> (lf, fileSize s)) <$> getFileStatus lf
|
||||
|
|
|
@ -41,6 +41,7 @@ handleRemoteProblem :: UrlRenderer -> Remote -> Assistant ()
|
|||
handleRemoteProblem urlrenderer rmt
|
||||
| Git.repoIsLocal r && not (Git.repoIsLocalUnknown r) =
|
||||
whenM (liftIO $ checkAvailable True rmt) $ do
|
||||
repairStaleGitLocks r
|
||||
fsckresults <- showFscking urlrenderer (Just $ Remote.name rmt) $ tryNonAsync $
|
||||
Git.Fsck.findBroken True r
|
||||
whenM (repairWhenNecessary urlrenderer (Remote.uuid rmt) (Just rmt) fsckresults) $
|
||||
|
@ -50,4 +51,5 @@ handleRemoteProblem urlrenderer rmt
|
|||
r = Remote.repo rmt
|
||||
|
||||
handleLocalRepoProblem :: UrlRenderer -> Assistant ()
|
||||
handleLocalRepoProblem urlrenderer = error "TODO"
|
||||
handleLocalRepoProblem urlrenderer = do
|
||||
repairStaleGitLocks =<< liftAnnex gitRepo
|
||||
|
|
|
@ -33,7 +33,7 @@ import Data.Time.Clock.POSIX
|
|||
- being nonresponsive.) -}
|
||||
sanityCheckerStartupThread :: Maybe Duration -> NamedThread
|
||||
sanityCheckerStartupThread startupdelay = namedThreadUnchecked "SanityCheckerStartup" $ do
|
||||
checkStaleGitLocks
|
||||
repairStaleGitLocks =<< liftAnnex gitRepo
|
||||
|
||||
liftIO $ maybe noop (threadDelaySeconds . Seconds . fromIntegral . durationSeconds) startupdelay
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue