summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Command/WebApp.hs23
-rw-r--r--debian/changelog1
-rw-r--r--doc/bugs/webapp_doesn__39__t_start_when___126____47__annex_isn__39__t_a_git_repo.mdwn2
3 files changed, 16 insertions, 10 deletions
diff --git a/Command/WebApp.hs b/Command/WebApp.hs
index 5256e8bb8..575d17330 100644
--- a/Command/WebApp.hs
+++ b/Command/WebApp.hs
@@ -59,13 +59,14 @@ start' :: Bool -> Maybe HostName -> CommandStart
start' allowauto listenhost = do
liftIO ensureInstalled
ifM isInitialized
- ( go
- , auto
+ ( maybe notinitialized (go <=< needsUpgrade) =<< getVersion
+ , if allowauto
+ then liftIO $ startNoRepo []
+ else notinitialized
)
stop
where
- go = do
- cannotrun <- needsUpgrade . fromMaybe (error "annex.version is not set.. seems this repository has not been initialized by git-annex") =<< getVersion
+ go cannotrun = do
browser <- fromRepo webBrowser
f <- liftIO . absPath =<< fromRepo gitAnnexHtmlShim
listenhost' <- if isJust listenhost
@@ -87,15 +88,14 @@ start' allowauto listenhost = do
then maybe noop (`hPutStrLn` url) origout
else openBrowser browser htmlshim url origout origerr
)
- auto
- | allowauto = liftIO $ startNoRepo []
- | otherwise = do
- d <- liftIO getCurrentDirectory
- error $ "no git repository in " ++ d
checkpid = do
pidfile <- fromRepo gitAnnexPidFile
liftIO $ isJust <$> checkDaemon pidfile
checkshim f = liftIO $ doesFileExist f
+ notinitialized = do
+ g <- Annex.gitRepo
+ liftIO $ cannotStartIn (Git.repoLocation g) "repository has not been initialized by git-annex"
+ liftIO $ firstRun listenhost
{- When run without a repo, start the first available listed repository in
- the autostart file. If none, it's our first time being run! -}
@@ -116,7 +116,7 @@ startNoRepo _ = do
Annex.new =<< Git.CurrentRepo.get
case v of
Left e -> do
- warningIO $ "unable to start webapp in " ++ d ++ ": " ++ show e
+ cannotStartIn d (show e)
go listenhost ds
Right state -> void $ Annex.eval state $ do
whenM (fromRepo Git.repoIsLocalBare) $
@@ -124,6 +124,9 @@ startNoRepo _ = do
callCommandAction $
start' False listenhost
+cannotStartIn :: FilePath -> String -> IO ()
+cannotStartIn d reason = warningIO $ "unable to start webapp in repository " ++ d ++ ": " ++ reason
+
{- Run the webapp without a repository, which prompts the user, makes one,
- changes to it, starts the regular assistant, and redirects the
- browser to its url.
diff --git a/debian/changelog b/debian/changelog
index 2beb79866..38a7f45d2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,7 @@ git-annex (5.20140518) UNRELEASED; urgency=medium
* assistant: When there are multiple remotes giving different ways
to access the same repository, honor remote cost settings and use
the cheapest available.
+ * webapp: More robust startup when annex directory is not a git repo.
-- Joey Hess <joeyh@debian.org> Mon, 19 May 2014 15:59:25 -0400
diff --git a/doc/bugs/webapp_doesn__39__t_start_when___126____47__annex_isn__39__t_a_git_repo.mdwn b/doc/bugs/webapp_doesn__39__t_start_when___126____47__annex_isn__39__t_a_git_repo.mdwn
index 6fd1c22b1..ac02590e6 100644
--- a/doc/bugs/webapp_doesn__39__t_start_when___126____47__annex_isn__39__t_a_git_repo.mdwn
+++ b/doc/bugs/webapp_doesn__39__t_start_when___126____47__annex_isn__39__t_a_git_repo.mdwn
@@ -25,3 +25,5 @@ $ /Applications/git-annex.app/Contents/MacOS/git-annex-webapp
git-annex: no git repository in /Users/lhunath/annex
# End of transcript or log.
"""]]
+
+> [[fixed|done]] --[[Joey]]