From f90839eada85dbccc29ee171d1b36020af342792 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 15 Sep 2014 14:45:37 -0400 Subject: assistant: Detect when repository has been deleted or moved, and automatically shut down the assistant. Closes: #761261 --- Assistant/Threads/SanityChecker.hs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'Assistant/Threads') diff --git a/Assistant/Threads/SanityChecker.hs b/Assistant/Threads/SanityChecker.hs index dce2c2db7..3371f212f 100644 --- a/Assistant/Threads/SanityChecker.hs +++ b/Assistant/Threads/SanityChecker.hs @@ -21,7 +21,9 @@ import Assistant.Drop import Assistant.Ssh import Assistant.TransferQueue import Assistant.Types.UrlRenderer +import Assistant.Restart import qualified Annex.Branch +import qualified Git import qualified Git.LsFiles import qualified Git.Command.Batch import qualified Git.Config @@ -146,6 +148,8 @@ waitForNextCheck = do - will block the watcher. -} dailyCheck :: UrlRenderer -> Assistant Bool dailyCheck urlrenderer = do + checkRepoExists + g <- liftAnnex gitRepo batchmaker <- liftIO getBatchCommandMaker @@ -203,6 +207,7 @@ dailyCheck urlrenderer = do hourlyCheck :: Assistant () hourlyCheck = do + checkRepoExists #ifndef mingw32_HOST_OS checkLogSize 0 #else @@ -316,3 +321,9 @@ cleanOld check f = go =<< catchMaybeIO getmtime getmtime = realToFrac . modificationTime <$> getSymbolicLinkStatus f go (Just mtime) | check mtime = nukeFile f go _ = noop + +checkRepoExists :: Assistant () +checkRepoExists = do + g <- liftAnnex gitRepo + liftIO $ unlessM (doesDirectoryExist $ Git.repoPath g) $ + terminateSelf -- cgit v1.2.3