Fix default cache handling in windows (#1272)
* Ignore all stack*.yaml.lock files * Use `$LOCALAPPDATA` environment variable in windows
This commit is contained in:
parent
17c28d4b6c
commit
640913f8d2
|
@ -22,4 +22,4 @@ cabal.project.local~
|
||||||
.ghc.environment.*
|
.ghc.environment.*
|
||||||
.cache
|
.cache
|
||||||
.history
|
.history
|
||||||
stack.yaml.lock
|
stack*.yaml.lock
|
||||||
|
|
|
@ -201,6 +201,7 @@ import qualified Dhall.Parser
|
||||||
import qualified Dhall.Pretty.Internal
|
import qualified Dhall.Pretty.Internal
|
||||||
import qualified Dhall.TypeCheck
|
import qualified Dhall.TypeCheck
|
||||||
import qualified System.Environment
|
import qualified System.Environment
|
||||||
|
import qualified System.Info
|
||||||
import qualified System.Directory as Directory
|
import qualified System.Directory as Directory
|
||||||
import qualified System.FilePath as FilePath
|
import qualified System.FilePath as FilePath
|
||||||
import qualified Text.Megaparsec
|
import qualified Text.Megaparsec
|
||||||
|
@ -792,12 +793,25 @@ getCacheDirectory = alternative₀ <|> alternative₁
|
||||||
Just xdgCacheHome -> return xdgCacheHome
|
Just xdgCacheHome -> return xdgCacheHome
|
||||||
Nothing -> empty
|
Nothing -> empty
|
||||||
|
|
||||||
alternative₁ = do
|
alternative₁
|
||||||
maybeHomeDirectory <- liftIO (System.Environment.lookupEnv "HOME")
|
| isWindows = do
|
||||||
|
maybeLocalAppDirectory <-
|
||||||
|
liftIO (System.Environment.lookupEnv "LOCALAPPDATA")
|
||||||
|
|
||||||
|
case maybeLocalAppDirectory of
|
||||||
|
Just localAppDirectory -> return localAppDirectory
|
||||||
|
Nothing -> empty
|
||||||
|
|
||||||
|
| otherwise = do
|
||||||
|
maybeHomeDirectory <-
|
||||||
|
liftIO (System.Environment.lookupEnv "HOME")
|
||||||
|
|
||||||
|
case maybeHomeDirectory of
|
||||||
|
Just homeDirectory -> return (homeDirectory </> ".cache")
|
||||||
|
Nothing -> empty
|
||||||
|
|
||||||
|
where isWindows = System.Info.os == "mingw32"
|
||||||
|
|
||||||
case maybeHomeDirectory of
|
|
||||||
Just homeDirectory -> return (homeDirectory </> ".cache")
|
|
||||||
Nothing -> empty
|
|
||||||
|
|
||||||
-- If the URL contains headers typecheck them and replace them with their normal
|
-- If the URL contains headers typecheck them and replace them with their normal
|
||||||
-- forms.
|
-- forms.
|
||||||
|
|
Loading…
Reference in New Issue