From 35f85f56fee33f200bb7ea0f8548a40d8e6c610c Mon Sep 17 00:00:00 2001 From: jkeDev <52346246+jkeDev@users.noreply.github.com> Date: Fri, 28 Jul 2023 19:46:49 +0200 Subject: [PATCH 1/2] Fixed #403 Hoogle will now use the `$XDG_DATA_DIR` instead of `~/.hoogle` as default path but still keep use the old one as a fallback. --- src/Action/CmdLine.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Action/CmdLine.hs b/src/Action/CmdLine.hs index 30266573..deccaf52 100644 --- a/src/Action/CmdLine.hs +++ b/src/Action/CmdLine.hs @@ -80,7 +80,10 @@ data CmdLine defaultDatabaseLang :: Language -> IO FilePath defaultDatabaseLang lang = do - dir <- getAppUserDataDirectory "hoogle" + xdgLocation <- getXdgDirectory XdgData "hoogle" + legacyLocation <- getAppUserDataDirectory "hoogle" + canIgnoreLegacyPath <- not <$> doesPathExist legacyLocation + let dir = if canIgnoreLegacyPath then xdgLocation else legacyLocation pure $ dir "default-" ++ lower (show lang) ++ "-" ++ showVersion (trimVersion 3 version) ++ ".hoo" getCmdLine :: [String] -> IO CmdLine From b4296368407832541853a5835f8a4ce6e0053931 Mon Sep 17 00:00:00 2001 From: Joschua Kesper Date: Thu, 8 Feb 2024 23:11:01 +0100 Subject: [PATCH 2/2] Deprecated legacy location --- CHANGES.txt | 1 + src/Action/CmdLine.hs | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index 15330cf8..17dd3979 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,5 +1,6 @@ Changelog for Hoogle (* = API change, @ = database format change) + #411, switched to xdg directory and depracted legacy location Require and support crypton-connection >= 0.4.1 5.0.18.4, released 2024-01-14 Don't test on GHC 9.2 or earlier diff --git a/src/Action/CmdLine.hs b/src/Action/CmdLine.hs index deccaf52..9543f26d 100644 --- a/src/Action/CmdLine.hs +++ b/src/Action/CmdLine.hs @@ -8,6 +8,7 @@ module Action.CmdLine( whenLoud, whenNormal ) where +import Control.Monad (unless) import Data.List.Extra import Data.Version import General.Util @@ -16,6 +17,7 @@ import System.Console.CmdArgs import System.Directory import System.Environment import System.FilePath +import System.IO data Language = Haskell | Frege deriving (Data,Typeable,Show,Eq,Enum,Bounded) @@ -83,6 +85,7 @@ defaultDatabaseLang lang = do xdgLocation <- getXdgDirectory XdgData "hoogle" legacyLocation <- getAppUserDataDirectory "hoogle" canIgnoreLegacyPath <- not <$> doesPathExist legacyLocation + unless canIgnoreLegacyPath (hPutStrLn stderr "Warning: ~/.hoogle is deprecated. Consider moving it to $XDG_DATA_HOME/hoogle (commonly ~/.local/share/hoogle)") let dir = if canIgnoreLegacyPath then xdgLocation else legacyLocation pure $ dir "default-" ++ lower (show lang) ++ "-" ++ showVersion (trimVersion 3 version) ++ ".hoo"