diff options
author | Joey Hess <joey@kitenet.net> | 2012-10-11 12:08:11 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-10-11 12:08:11 -0400 |
commit | 03c1a1906bbd96538d41a40622d0e565de527dd2 (patch) | |
tree | 9b8adb487ef4bc9c0a233c868ea52dff457cc693 /Command | |
parent | 833e1bbd14d514d724443abc8050273d5524a673 (diff) |
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.
Diffstat (limited to 'Command')
-rw-r--r-- | Command/WebApp.hs | 14 |
1 files changed, 11 insertions, 3 deletions
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 |