git.iko.soy/typeable/pandoc
on master help sign in
Shared: Change defaultUserDataDirs -> defaultUserDataDir.

Rationale: the manual says that the XDG data directory will be used if it exists, otherwise the legacy data directory. So we should just determine this and use this directory, rather than having a search path which could cause some things to be taken from one data directory and others from others. [API change]

commit31d007c4f9b17e474c267aeceffcabece07e2c44 authorJohn MacFarlane <jgm@berkeley.edu> dateFri 5 Mar 2021, 10:20 (6 years ago) parentd74b6b8
2 files changed+18−14
MANUAL.txt+6−6 src/Text/Pandoc/Shared.hs+12−8
MANUAL.txt+6−6
@@ -361,15 +361,15 @@ header when requesting a document from a URL:
361361 will be used. On \*nix and macOS systems this will be the `pandoc`
362362 subdirectory of the XDG data directory (by default,
363363 `$HOME/.local/share`, overridable by setting the `XDG_DATA_HOME`
364− environment variable). If that directory does not exist,
365− `$HOME/.pandoc` will be used (for backwards compatibility).
366− In Windows the default user data directory is
364+ environment variable). If that directory does not exist and
365+ `$HOME/.pandoc` exists, it will be used (for backwards compatibility).
366+ On Windows the default user data directory is
367367 `C:\Users\USERNAME\AppData\Roaming\pandoc`.
368368 You can find the default user data directory on your system by
369369 looking at the output of `pandoc --version`.
370− A `reference.odt`, `reference.docx`, `epub.css`, `templates`,
371− `slidy`, `slideous`, or `s5` directory
372− placed in this directory will override pandoc's normal defaults.
370+ Data files placed in this directory (for example, `reference.odt`,
371+ `reference.docx`, `epub.css`, `templates`) will override
372+ pandoc's normal defaults.
373373
374374`-d` *FILE*, `--defaults=`*FILE*
375375
src/Text/Pandoc/Shared.hs+12−8
@@ -95,7 +95,7 @@ module Text.Pandoc.Shared (
9595 safeRead,
9696 safeStrRead,
9797 -- * User data directory
98− defaultUserDataDirs,
98+ defaultUserDataDir,
9999 -- * Version
100100 pandocVersion
101101 ) where
@@ -1012,12 +1012,16 @@ safeStrRead s = case reads s of
10121012--
10131013
10141014-- | Return appropriate user data directory for platform. We use
1015−-- XDG_DATA_HOME (or its default value), but fall back to the
1016−-- legacy user data directory ($HOME/.pandoc on *nix) if this is
1017−-- missing.
1018−defaultUserDataDirs :: IO [FilePath]
1019−defaultUserDataDirs = E.catch (do
1015+-- XDG_DATA_HOME (or its default value), but for backwards compatibility,
1016+-- we fall back to the legacy user data directory ($HOME/.pandoc on *nix)
1017+-- if the XDG_DATA_HOME is missing and this exists. If neither directory
1018+-- is present, we return the XDG data directory.
1019+defaultUserDataDir :: IO FilePath
1020+defaultUserDataDir = do
10201021 xdgDir <- getXdgDirectory XdgData "pandoc"
10211022 legacyDir <- getAppUserDataDirectory "pandoc"
1022− return $ ordNub [xdgDir, legacyDir])
1023− (\(_ :: E.SomeException) -> return [])
1023+ xdgExists <- doesDirectoryExist xdgDir
1024+ legacyDirExists <- doesDirectoryExist legacyDir
1025+ if not xdgExists && legacyDirExists
1026+ then return legacyDir
1027+ else return xdgDir