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
|
- 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.
|
- file, since git does so by writing the new content to index.lock.
|
||||||
-}
|
-}
|
||||||
checkStaleGitLocks :: Assistant ()
|
repairStaleGitLocks :: Git.Repo -> Assistant ()
|
||||||
checkStaleGitLocks = do
|
repairStaleGitLocks r = do
|
||||||
lockfiles <- filter (not . isInfixOf "gc.pid")
|
lockfiles <- filter (not . isInfixOf "gc.pid")
|
||||||
. filter (".lock" `isSuffixOf`)
|
. filter (".lock" `isSuffixOf`)
|
||||||
<$> (liftIO . dirContentsRecursiveSkipping (== dropTrailingPathSeparator annexDir)
|
<$> liftIO (findgitfiles r)
|
||||||
=<< liftAnnex (fromRepo Git.localGitDir))
|
repairStaleLocks lockfiles
|
||||||
checkStaleLocks lockfiles
|
where
|
||||||
checkStaleLocks :: [FilePath] -> Assistant ()
|
findgitfiles = dirContentsRecursiveSkipping (== dropTrailingPathSeparator annexDir) . Git.localGitDir
|
||||||
checkStaleLocks lockfiles = go =<< getsizes
|
repairStaleLocks :: [FilePath] -> Assistant ()
|
||||||
|
repairStaleLocks lockfiles = go =<< getsizes
|
||||||
where
|
where
|
||||||
getsize lf = catchMaybeIO $
|
getsize lf = catchMaybeIO $
|
||||||
(\s -> (lf, fileSize s)) <$> getFileStatus lf
|
(\s -> (lf, fileSize s)) <$> getFileStatus lf
|
||||||
|
|
|
@ -41,6 +41,7 @@ handleRemoteProblem :: UrlRenderer -> Remote -> Assistant ()
|
||||||
handleRemoteProblem urlrenderer rmt
|
handleRemoteProblem urlrenderer rmt
|
||||||
| Git.repoIsLocal r && not (Git.repoIsLocalUnknown r) =
|
| Git.repoIsLocal r && not (Git.repoIsLocalUnknown r) =
|
||||||
whenM (liftIO $ checkAvailable True rmt) $ do
|
whenM (liftIO $ checkAvailable True rmt) $ do
|
||||||
|
repairStaleGitLocks r
|
||||||
fsckresults <- showFscking urlrenderer (Just $ Remote.name rmt) $ tryNonAsync $
|
fsckresults <- showFscking urlrenderer (Just $ Remote.name rmt) $ tryNonAsync $
|
||||||
Git.Fsck.findBroken True r
|
Git.Fsck.findBroken True r
|
||||||
whenM (repairWhenNecessary urlrenderer (Remote.uuid rmt) (Just rmt) fsckresults) $
|
whenM (repairWhenNecessary urlrenderer (Remote.uuid rmt) (Just rmt) fsckresults) $
|
||||||
|
@ -50,4 +51,5 @@ handleRemoteProblem urlrenderer rmt
|
||||||
r = Remote.repo rmt
|
r = Remote.repo rmt
|
||||||
|
|
||||||
handleLocalRepoProblem :: UrlRenderer -> Assistant ()
|
handleLocalRepoProblem :: UrlRenderer -> Assistant ()
|
||||||
handleLocalRepoProblem urlrenderer = error "TODO"
|
handleLocalRepoProblem urlrenderer = do
|
||||||
|
repairStaleGitLocks =<< liftAnnex gitRepo
|
||||||
|
|
|
@ -33,7 +33,7 @@ import Data.Time.Clock.POSIX
|
||||||
- being nonresponsive.) -}
|
- being nonresponsive.) -}
|
||||||
sanityCheckerStartupThread :: Maybe Duration -> NamedThread
|
sanityCheckerStartupThread :: Maybe Duration -> NamedThread
|
||||||
sanityCheckerStartupThread startupdelay = namedThreadUnchecked "SanityCheckerStartup" $ do
|
sanityCheckerStartupThread startupdelay = namedThreadUnchecked "SanityCheckerStartup" $ do
|
||||||
checkStaleGitLocks
|
repairStaleGitLocks =<< liftAnnex gitRepo
|
||||||
|
|
||||||
liftIO $ maybe noop (threadDelaySeconds . Seconds . fromIntegral . durationSeconds) startupdelay
|
liftIO $ maybe noop (threadDelaySeconds . Seconds . fromIntegral . durationSeconds) startupdelay
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue