webapp: When $HOME is a git repository, and has been initialized for use by git-annex, opening the webapp went ahead and ran the assistant there, annexing all files. Since this is almost certianly not desirable, especially when the user is just opening the webapp from a dekstop menu which happens to run it in $HOME, the webapp will now not treat such a $HOME git repository as a git-annex repository.

This commit is contained in:
Joey Hess 2016-04-13 14:07:50 -04:00
parent fe1628db11
commit 1010482bc7
Failed to extract signature
4 changed files with 43 additions and 1 deletions

View file

@ -22,6 +22,7 @@ import Utility.Daemon (checkDaemon)
#ifdef __ANDROID__
import Utility.Env
#endif
import Utility.UserInfo
import Annex.Init
import qualified Git
import qualified Git.Config
@ -60,7 +61,7 @@ start = start' True
start' :: Bool -> WebAppOptions -> CommandStart
start' allowauto o = do
liftIO ensureInstalled
ifM isInitialized
ifM (isInitialized <&&> notHome)
( maybe notinitialized (go <=< needsUpgrade) =<< getVersion
, if allowauto
then liftIO $ startNoRepo o
@ -99,6 +100,15 @@ start' allowauto o = do
liftIO $ cannotStartIn (Git.repoLocation g) "repository has not been initialized by git-annex"
liftIO $ firstRun o
{- If HOME is a git repo, even if it's initialized for git-annex,
- the user almost certianly does not want to run the assistant there. -}
notHome :: Annex Bool
notHome = do
g <- Annex.gitRepo
d <- liftIO $ absPath (Git.repoLocation g)
h <- liftIO $ absPath =<< myHomeDir
return (d /= h)
{- When run without a repo, start the first available listed repository in
- the autostart file. If none, it's our first time being run! -}
startNoRepo :: WebAppOptions -> IO ()