check that ~/Desktop/annex can be written to; fall back to ~/annex when not

This commit is contained in:
Joey Hess 2013-12-24 17:04:07 -04:00
parent 706c74aa98
commit 8e58ff7f71
2 changed files with 12 additions and 3 deletions

View file

@ -124,17 +124,20 @@ defaultRepositoryPath firstrun = do
, inhome , inhome
) )
#else #else
-- Windows user can probably write anywhere, so always default -- On Windows, always default to ~/Desktop/annex or ~/annex,
-- to ~/Desktop/annex. -- no cwd handling because the user might be able to write
-- to the entire drive.
inhome inhome
#endif #endif
where where
inhome = do inhome = do
desktop <- userDesktopDir desktop <- userDesktopDir
ifM (doesDirectoryExist desktop) ifM (doesDirectoryExist desktop <&&> canWrite desktop)
( relHome $ desktop </> gitAnnexAssistantDefaultDir ( relHome $ desktop </> gitAnnexAssistantDefaultDir
, return $ "~" </> gitAnnexAssistantDefaultDir , return $ "~" </> gitAnnexAssistantDefaultDir
) )
-- Avoid using eg, standalone build's git-annex.linux/ directory
-- when run from there.
legit d = not <$> doesFileExist (d </> "git-annex") legit d = not <$> doesFileExist (d </> "git-annex")
newRepositoryForm :: FilePath -> Hamlet.Html -> MkMForm RepositoryPath newRepositoryForm :: FilePath -> Hamlet.Html -> MkMForm RepositoryPath

View file

@ -24,3 +24,9 @@ Windows 7 64-bit
[[!format sh """ [[!format sh """
Launching web browser on file://C:\Users\bbigras\AppData\Local\Temp\webapp9924.html Launching web browser on file://C:\Users\bbigras\AppData\Local\Temp\webapp9924.html
"""]] """]]
> It checks if the directory can be written to, and it seems that for some
> reason Windows is preventing you from writing to your Desktop. That seems
> really weird to me (and I have not seen that behavior). But, I can easily
> make it check if that's the case, and fall back to the other path, so
> have done so. [[done]] --[[Joey]]