assistant: Detect when repository has been deleted or moved, and automatically shut down the assistant. Closes: #761261

This commit is contained in:
Joey Hess 2014-09-15 14:45:37 -04:00
parent 4e3d176b1b
commit 09e20c3827
4 changed files with 24 additions and 6 deletions

View file

@ -53,6 +53,10 @@ postRestart url = do
liftIO . sendNotification . globalRedirNotifier =<< getDaemonStatus liftIO . sendNotification . globalRedirNotifier =<< getDaemonStatus
void $ liftIO $ forkIO $ do void $ liftIO $ forkIO $ do
threadDelaySeconds (Seconds 120) threadDelaySeconds (Seconds 120)
terminateSelf
terminateSelf :: IO ()
terminateSelf =
#ifndef mingw32_HOST_OS #ifndef mingw32_HOST_OS
signalProcess sigTERM =<< getPID signalProcess sigTERM =<< getPID
#else #else

View file

@ -21,7 +21,9 @@ import Assistant.Drop
import Assistant.Ssh import Assistant.Ssh
import Assistant.TransferQueue import Assistant.TransferQueue
import Assistant.Types.UrlRenderer import Assistant.Types.UrlRenderer
import Assistant.Restart
import qualified Annex.Branch import qualified Annex.Branch
import qualified Git
import qualified Git.LsFiles import qualified Git.LsFiles
import qualified Git.Command.Batch import qualified Git.Command.Batch
import qualified Git.Config import qualified Git.Config
@ -146,6 +148,8 @@ waitForNextCheck = do
- will block the watcher. -} - will block the watcher. -}
dailyCheck :: UrlRenderer -> Assistant Bool dailyCheck :: UrlRenderer -> Assistant Bool
dailyCheck urlrenderer = do dailyCheck urlrenderer = do
checkRepoExists
g <- liftAnnex gitRepo g <- liftAnnex gitRepo
batchmaker <- liftIO getBatchCommandMaker batchmaker <- liftIO getBatchCommandMaker
@ -203,6 +207,7 @@ dailyCheck urlrenderer = do
hourlyCheck :: Assistant () hourlyCheck :: Assistant ()
hourlyCheck = do hourlyCheck = do
checkRepoExists
#ifndef mingw32_HOST_OS #ifndef mingw32_HOST_OS
checkLogSize 0 checkLogSize 0
#else #else
@ -316,3 +321,9 @@ cleanOld check f = go =<< catchMaybeIO getmtime
getmtime = realToFrac . modificationTime <$> getSymbolicLinkStatus f getmtime = realToFrac . modificationTime <$> getSymbolicLinkStatus f
go (Just mtime) | check mtime = nukeFile f go (Just mtime) | check mtime = nukeFile f
go _ = noop go _ = noop
checkRepoExists :: Assistant ()
checkRepoExists = do
g <- liftAnnex gitRepo
liftIO $ unlessM (doesDirectoryExist $ Git.repoPath g) $
terminateSelf

View file

@ -53,15 +53,11 @@ getShutdownConfirmedR = do
- page time to load in the browser. -} - page time to load in the browser. -}
void $ liftIO $ forkIO $ do void $ liftIO $ forkIO $ do
threadDelay 2000000 threadDelay 2000000
#ifndef mingw32_HOST_OS terminateSelf
signalProcess sigTERM =<< getPID
#else
terminatePID =<< getPID
#endif
redirect NotRunningR redirect NotRunningR
{- Use a custom page to avoid putting long polling elements on it that will {- Use a custom page to avoid putting long polling elements on it that will
- fail and cause the web browser to show an error once the webapp is - fail and cause thet web browser to show an error once the webapp is
- truely stopped. -} - truely stopped. -}
getNotRunningR :: Handler Html getNotRunningR :: Handler Html
getNotRunningR = customPage' False Nothing $ getNotRunningR = customPage' False Nothing $

7
debian/changelog vendored
View file

@ -1,3 +1,10 @@
git-annex (5.20140916) UNRELEASED; urgency=medium
* assistant: Detect when repository has been deleted or moved, and
automatically shut down the assistant. Closes: #761261
-- Joey Hess <joeyh@debian.org> Mon, 15 Sep 2014 14:39:17 -0400
git-annex (5.20140915) unstable; urgency=medium git-annex (5.20140915) unstable; urgency=medium
* New annex.hardlink setting. Closes: #758593 * New annex.hardlink setting. Closes: #758593