From 03c1a1906bbd96538d41a40622d0e565de527dd2 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 11 Oct 2012 12:08:11 -0400 Subject: webapp: avoid infinite loop on start If the autostart file lists a repository, for which a directory exists, but there's not actually a valid git repo in there, the web app used to try to use it, and see it wasn't valid, and then try to autostart again. The ensuing runaway loop also ate memory, although not as fast as I was led to belive was happening to someone on IRC yesterday. So that guy may have had a different problem. But this seems otherwise a reasonable fit for the circumstances described, if git-annex was started before something that occurred during desktop login that made the repository available. --- Command/WebApp.hs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'Command/WebApp.hs') diff --git a/Command/WebApp.hs b/Command/WebApp.hs index 7ad6566c9..702506d34 100644 --- a/Command/WebApp.hs +++ b/Command/WebApp.hs @@ -39,9 +39,12 @@ seek :: [CommandSeek] seek = [withNothing start] start :: CommandStart -start = notBareRepo $ do +start = start' True + +start' :: Bool -> CommandStart +start' allowauto = notBareRepo $ do liftIO $ ensureInstalled - ifM isInitialized ( go , liftIO startNoRepo ) + ifM isInitialized ( go , auto ) stop where go = do @@ -52,6 +55,11 @@ start = notBareRepo $ do , startDaemon True True $ Just $ const $ openBrowser browser ) + auto + | allowauto = liftIO startNoRepo + | otherwise = do + d <- liftIO getCurrentDirectory + error $ "no repository for " ++ d checkpid = do pidfile <- fromRepo gitAnnexPidFile liftIO $ isJust <$> checkDaemon pidfile @@ -74,7 +82,7 @@ autoStart autostartfile = do (d:_) -> do changeWorkingDirectory d state <- Annex.new =<< Git.CurrentRepo.get - void $ Annex.eval state $ doCommand start + void $ Annex.eval state $ doCommand $ start' False {- Run the webapp without a repository, which prompts the user, makes one, - changes to it, starts the regular assistant, and redirects the -- cgit v1.2.3