Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #403 #411

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 7 additions & 1 deletion src/Action/CmdLine.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module Action.CmdLine(
whenLoud, whenNormal
) where

import Control.Monad (unless)
import Data.List.Extra
import Data.Version
import General.Util
Expand All @@ -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)

Expand Down Expand Up @@ -80,7 +82,11 @@ data CmdLine

defaultDatabaseLang :: Language -> IO FilePath
defaultDatabaseLang lang = do
dir <- getAppUserDataDirectory "hoogle"
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"

getCmdLine :: [String] -> IO CmdLine
Expand Down