A suggestion to turn defaultUserDataDir :: IO FilePath into defaultUserDataDirs :: IO [FilePath]
Some checks failed
CI tests / linux (map[cabal:3.2 cabalopts: ghc:8.10.7 testopts:--test-option=--hide-successes --test-option=--ansi-tricks=false]) (push) Has been cancelled
CI tests / linux (map[cabal:3.2 cabalopts: ghc:8.8.4 testopts:--test-option=--hide-successes --test-option=--ansi-tricks=false]) (push) Has been cancelled
CI tests / linux (map[cabal:3.2 cabalopts:-f-embed_data_files ghc:8.6.5 testopts:--test-option=--hide-successes --test-option=--ansi-tricks=false]) (push) Has been cancelled
CI tests / linux (map[cabal:3.4 cabalopts: ghc:9.0.2 testopts:--test-option=--hide-successes --test-option=--ansi-tricks=false]) (push) Has been cancelled
CI tests / linux (map[cabal:3.6 cabalopts: ghc:9.2.3 testopts:--test-option=--hide-successes --test-option=--ansi-tricks=false]) (push) Has been cancelled
CI tests / windows (push) Has been cancelled
CI tests / macos (map[cabal:3.2 ghc:8.8.4]) (push) Has been cancelled
CI tests / benchmark (map[cabal:3.2 ghc:8.10.7]) (push) Has been cancelled
CI tests / benchmark (map[cabal:3.6 ghc:9.2.2]) (push) Has been cancelled
commit-validation / check-commit-msg-length (push) Has been cancelled

This commit is contained in:
Tissevert 2025-01-11 12:25:41 +01:00
parent 373423d537
commit b84554880d

View file

@ -92,7 +92,7 @@ module Text.Pandoc.Shared (
safeRead, safeRead,
safeStrRead, safeStrRead,
-- * User data directory -- * User data directory
defaultUserDataDir, defaultUserDataDirs,
-- * Version -- * Version
pandocVersion pandocVersion
) where ) where
@ -1017,13 +1017,15 @@ safeStrRead s = case reads s of
-- is present, we return the XDG data directory. If 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 -- is not defined (e.g. because we are in an environment where $HOME is
-- not defined), we return the empty string. -- not defined), we return the empty string.
defaultUserDataDir :: IO FilePath defaultUserDataDirs :: IO [FilePath]
defaultUserDataDir = do defaultUserDataDirs = do
xdgDir <- E.catch (getXdgDirectory XdgData "pandoc") xdgDir <- E.catch (getXdgDirectory XdgData "pandoc")
(\(_ :: E.SomeException) -> return mempty) (\(_ :: E.SomeException) -> return mempty)
legacyDir <- getAppUserDataDirectory "pandoc" legacyDir <- getAppUserDataDirectory "pandoc"
xdgExists <- doesDirectoryExist xdgDir xdgExists <- doesDirectoryExist xdgDir
legacyDirExists <- doesDirectoryExist legacyDir legacyDirExists <- doesDirectoryExist legacyDir
if not xdgExists && legacyDirExists let mainDir = if not xdgExists && legacyDirExists then legacyDir else xdgDir
then return legacyDir xdgDirs <- E.catch (getXdgDirectoryList XdgDataDirs)
else return xdgDir (\(_ :: E.SomeException) -> return mempty)
return (mainDir:xdgDirs)