webapp: More robust startup when annex directory is not a git repo or not intialized by git-annex.
This commit is contained in:
parent
902599248c
commit
9adcf8fff5
3 changed files with 16 additions and 10 deletions
|
@ -59,13 +59,14 @@ start' :: Bool -> Maybe HostName -> CommandStart
|
||||||
start' allowauto listenhost = do
|
start' allowauto listenhost = do
|
||||||
liftIO ensureInstalled
|
liftIO ensureInstalled
|
||||||
ifM isInitialized
|
ifM isInitialized
|
||||||
( go
|
( maybe notinitialized (go <=< needsUpgrade) =<< getVersion
|
||||||
, auto
|
, if allowauto
|
||||||
|
then liftIO $ startNoRepo []
|
||||||
|
else notinitialized
|
||||||
)
|
)
|
||||||
stop
|
stop
|
||||||
where
|
where
|
||||||
go = do
|
go cannotrun = do
|
||||||
cannotrun <- needsUpgrade . fromMaybe (error "annex.version is not set.. seems this repository has not been initialized by git-annex") =<< getVersion
|
|
||||||
browser <- fromRepo webBrowser
|
browser <- fromRepo webBrowser
|
||||||
f <- liftIO . absPath =<< fromRepo gitAnnexHtmlShim
|
f <- liftIO . absPath =<< fromRepo gitAnnexHtmlShim
|
||||||
listenhost' <- if isJust listenhost
|
listenhost' <- if isJust listenhost
|
||||||
|
@ -87,15 +88,14 @@ start' allowauto listenhost = do
|
||||||
then maybe noop (`hPutStrLn` url) origout
|
then maybe noop (`hPutStrLn` url) origout
|
||||||
else openBrowser browser htmlshim url origout origerr
|
else openBrowser browser htmlshim url origout origerr
|
||||||
)
|
)
|
||||||
auto
|
|
||||||
| allowauto = liftIO $ startNoRepo []
|
|
||||||
| otherwise = do
|
|
||||||
d <- liftIO getCurrentDirectory
|
|
||||||
error $ "no git repository in " ++ d
|
|
||||||
checkpid = do
|
checkpid = do
|
||||||
pidfile <- fromRepo gitAnnexPidFile
|
pidfile <- fromRepo gitAnnexPidFile
|
||||||
liftIO $ isJust <$> checkDaemon pidfile
|
liftIO $ isJust <$> checkDaemon pidfile
|
||||||
checkshim f = liftIO $ doesFileExist f
|
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
|
{- When run without a repo, start the first available listed repository in
|
||||||
- the autostart file. If none, it's our first time being run! -}
|
- the autostart file. If none, it's our first time being run! -}
|
||||||
|
@ -116,7 +116,7 @@ startNoRepo _ = do
|
||||||
Annex.new =<< Git.CurrentRepo.get
|
Annex.new =<< Git.CurrentRepo.get
|
||||||
case v of
|
case v of
|
||||||
Left e -> do
|
Left e -> do
|
||||||
warningIO $ "unable to start webapp in " ++ d ++ ": " ++ show e
|
cannotStartIn d (show e)
|
||||||
go listenhost ds
|
go listenhost ds
|
||||||
Right state -> void $ Annex.eval state $ do
|
Right state -> void $ Annex.eval state $ do
|
||||||
whenM (fromRepo Git.repoIsLocalBare) $
|
whenM (fromRepo Git.repoIsLocalBare) $
|
||||||
|
@ -124,6 +124,9 @@ startNoRepo _ = do
|
||||||
callCommandAction $
|
callCommandAction $
|
||||||
start' False listenhost
|
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,
|
{- Run the webapp without a repository, which prompts the user, makes one,
|
||||||
- changes to it, starts the regular assistant, and redirects the
|
- changes to it, starts the regular assistant, and redirects the
|
||||||
- browser to its url.
|
- browser to its url.
|
||||||
|
|
1
debian/changelog
vendored
1
debian/changelog
vendored
|
@ -3,6 +3,7 @@ git-annex (5.20140518) UNRELEASED; urgency=medium
|
||||||
* assistant: When there are multiple remotes giving different ways
|
* assistant: When there are multiple remotes giving different ways
|
||||||
to access the same repository, honor remote cost settings and use
|
to access the same repository, honor remote cost settings and use
|
||||||
the cheapest available.
|
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
|
-- Joey Hess <joeyh@debian.org> Mon, 19 May 2014 15:59:25 -0400
|
||||||
|
|
||||||
|
|
|
@ -25,3 +25,5 @@ $ /Applications/git-annex.app/Contents/MacOS/git-annex-webapp
|
||||||
git-annex: no git repository in /Users/lhunath/annex
|
git-annex: no git repository in /Users/lhunath/annex
|
||||||
# End of transcript or log.
|
# End of transcript or log.
|
||||||
"""]]
|
"""]]
|
||||||
|
|
||||||
|
> [[fixed|done]] --[[Joey]]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue