T.P.Shared.defaultUserDataDir: behavior change.
If the XDG data directory is not defined (e.g. because it's not supported in the OS or HOME isn't defined), we return the empty string instead of raising an exception. Closes #7842.
This commit is contained in:
parent
5811baf80f
commit
a92ae0a58a
1 changed files with 5 additions and 2 deletions
|
@ -965,10 +965,13 @@ safeStrRead s = case reads s of
|
||||||
-- XDG_DATA_HOME (or its default value), but for backwards compatibility,
|
-- XDG_DATA_HOME (or its default value), but for backwards compatibility,
|
||||||
-- we fall back to the legacy user data directory ($HOME/.pandoc on *nix)
|
-- we fall back to the legacy user data directory ($HOME/.pandoc on *nix)
|
||||||
-- if the XDG_DATA_HOME is missing and this exists. If neither directory
|
-- if the XDG_DATA_HOME is missing and this exists. If neither directory
|
||||||
-- is present, we return the XDG data directory.
|
-- is present, we return the XDG data directory. If the XDG data directory
|
||||||
|
-- is not defined (e.g. because we are in an environment where $HOME is
|
||||||
|
-- not defined), we return the empty string.
|
||||||
defaultUserDataDir :: IO FilePath
|
defaultUserDataDir :: IO FilePath
|
||||||
defaultUserDataDir = do
|
defaultUserDataDir = do
|
||||||
xdgDir <- getXdgDirectory XdgData "pandoc"
|
xdgDir <- E.catch (getXdgDirectory XdgData "pandoc")
|
||||||
|
(\(_ :: E.SomeException) -> return mempty)
|
||||||
legacyDir <- getAppUserDataDirectory "pandoc"
|
legacyDir <- getAppUserDataDirectory "pandoc"
|
||||||
xdgExists <- doesDirectoryExist xdgDir
|
xdgExists <- doesDirectoryExist xdgDir
|
||||||
legacyDirExists <- doesDirectoryExist legacyDir
|
legacyDirExists <- doesDirectoryExist legacyDir
|
||||||
|
|
Loading…
Reference in a new issue