Skip to content

Commit 96202ba

Browse files
authored
Use TMP and TMPDIR #256 (#257)
* Use TMP and TMPDIR #256 Use TMP and TMPDIR as defaults for the tmp directory * Add lifts * Bump version * Update CHANGELOG * Import Control.Applicative
1 parent 3f47124 commit 96202ba

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
Changelog for tmp-postgres
2+
- 1.35.0.0
3+
- #256 Use TMP and TMPDIR as defaults for the tmp directory
4+
25
- 1.34.1.0
36
- #229 Add a `auto_explain` config
47

src/Database/Postgres/Temp/Internal/Config.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import System.IO.Temp (createTempDirectory)
4545
import System.IO.Unsafe (unsafePerformIO)
4646
import System.Process
4747
import Text.PrettyPrint.ANSI.Leijen hiding ((<$>))
48+
import Control.Applicative
4849

4950
{-|
5051
@@ -785,7 +786,10 @@ setupConfig
785786
setupConfig config@Config {..} = evalContT $ do
786787
envs <- lift getEnvironment
787788
thePort <- lift $ maybe getFreePort pure $ join $ getLast port
788-
let resourcesTemporaryDir = fromMaybe "/tmp" $ getLast temporaryDirectory
789+
tmpEnv <- lift $ lookupEnv "TMP"
790+
tmpDirEnv <- lift $ lookupEnv "TMPDIR"
791+
let defaultTemp = fromMaybe "/tmp" $ tmpEnv <|> tmpDirEnv
792+
resourcesTemporaryDir = fromMaybe defaultTemp $ getLast temporaryDirectory
789793
resourcesInitDbCache = join $ getLast initDbCache
790794
resourcesSocketDirectory <- ContT $ bracketOnError
791795
(setupDirectoryType resourcesTemporaryDir "tmp-postgres-socket" socketDirectory) cleanupDirectoryType

tmp-postgres.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: tmp-postgres
2-
version: 1.34.1.0
2+
version: 1.35.0.0
33
synopsis: Start and stop a temporary postgres
44
description: Start and stop a temporary postgres. See README.md
55
homepage: https://github.com/jfischoff/tmp-postgres#readme

0 commit comments

Comments
 (0)