webapp: Don't default to making repository in cwd when started from within a directory containing a git-annex file (eg, standalone tarball directory).

This commit is contained in:
Joey Hess 2013-04-20 18:53:04 -04:00
parent 780ed8ebf1
commit 4ddf9b7467
2 changed files with 12 additions and 3 deletions

View file

@ -98,14 +98,19 @@ checkRepositoryPath p = do
- ~/Desktop/annex, when a Desktop directory exists, and ~/annex otherwise. - ~/Desktop/annex, when a Desktop directory exists, and ~/annex otherwise.
- -
- If run in another directory, that the user can write to, - If run in another directory, that the user can write to,
- the user probably wants to put it there. -} - the user probably wants to put it there. Unless that directory
- contains a git-annex file, in which case the user has probably
- browsed to a directory with git-annex and run it from there. -}
defaultRepositoryPath :: Bool -> IO FilePath defaultRepositoryPath :: Bool -> IO FilePath
defaultRepositoryPath firstrun = do defaultRepositoryPath firstrun = do
cwd <- liftIO $ getCurrentDirectory cwd <- liftIO $ getCurrentDirectory
home <- myHomeDir home <- myHomeDir
if home == cwd && firstrun if home == cwd && firstrun
then inhome then inhome
else ifM (canWrite cwd) ( return cwd, inhome ) else ifM (legit cwd <&&> canWrite cwd)
( return cwd
, inhome
)
where where
inhome = do inhome = do
desktop <- userDesktopDir desktop <- userDesktopDir
@ -113,6 +118,7 @@ defaultRepositoryPath firstrun = do
( relHome $ desktop </> gitAnnexAssistantDefaultDir ( relHome $ desktop </> gitAnnexAssistantDefaultDir
, return $ "~" </> gitAnnexAssistantDefaultDir , return $ "~" </> gitAnnexAssistantDefaultDir
) )
legit d = not <$> doesFileExist (d </> "git-annex")
newRepositoryForm :: FilePath -> Form RepositoryPath newRepositoryForm :: FilePath -> Form RepositoryPath
newRepositoryForm defpath msg = do newRepositoryForm defpath msg = do

5
debian/changelog vendored
View file

@ -2,7 +2,10 @@ git-annex (4.20130418) UNRELEASED; urgency=low
* assistant: Work around misfeature in git 1.8.2 that makes * assistant: Work around misfeature in git 1.8.2 that makes
`git commit --alow-empty -m ""` run an editor. `git commit --alow-empty -m ""` run an editor.
* Install FDO desktop menu file when webapp is started in standalone mode. * webapp: Install FDO desktop menu file when started in standalone mode.
* webapp: Don't default to making repository in cwd when started
from within a directory containing a git-annex file (eg, standalone
tarball directory).
-- Joey Hess <joeyh@debian.org> Thu, 18 Apr 2013 16:22:48 -0400 -- Joey Hess <joeyh@debian.org> Thu, 18 Apr 2013 16:22:48 -0400