Skip to content

Commit b938dc0

Browse files
committed
data dir checks to fix installation with scarf
1 parent ffcdf4d commit b938dc0

File tree

4 files changed

+24
-40
lines changed

4 files changed

+24
-40
lines changed

app/Main.hs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,34 @@ import Paths_toodles
88
import Server
99
import Types
1010

11+
import Control.Monad (when)
1112
import Data.IORef (newIORef)
1213
import Data.Maybe (fromMaybe)
1314
import qualified Data.Text as T (unpack)
1415
import Network.Wai.Handler.Warp (run)
16+
import System.Directory
17+
import System.Environment
18+
import System.FilePath.Posix
1519
import Text.Printf (printf)
1620

1721
main :: IO ()
1822
main = do
19-
dataDir <- getDataDir
20-
licenseRead <- readLicense (dataDir ++ "/toodles-license-public-key.pem") "/etc/toodles/license.json"
23+
dataDirLocal <- (return . takeDirectory) =<< getExecutablePath
24+
dataDirBuilt <- getDataDir
25+
useBinaryLocalDataDir <- doesDirectoryExist $ dataDirLocal <> "/web"
26+
useBuiltDataDir <- doesDirectoryExist $ dataDirBuilt <> "/web"
27+
when
28+
(not useBuiltDataDir && not useBuiltDataDir)
29+
(fail
30+
"Couldn't initialize toodles, no valid data directory found. Please file a bug on Github.")
31+
let dataDir =
32+
if useBinaryLocalDataDir
33+
then dataDirLocal
34+
else dataDirBuilt
35+
licenseRead <-
36+
readLicense
37+
(dataDir ++ "/toodles-license-public-key.pem")
38+
"/etc/toodles/license.json"
2139
let license = (either (BadLicense) (id) licenseRead)
2240
userArgs <- toodlesArgs >>= setAbsolutePath
2341
case userArgs of

package.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: toodles
2-
version: 1.2.1
2+
version: 1.2.2
33
github: "aviaviavi/toodles"
44
license: MIT
55
author: "Avi Press"
@@ -92,6 +92,7 @@ executables:
9292
- cmdargs ==0.10.20
9393
- directory ==1.3.1.5
9494
- extra ==1.6.13
95+
- filepath ==1.4.2
9596
- megaparsec ==6.5.0
9697
- process >=1.6.3.0
9798
- regex-posix ==0.95.2

toodles-scarf.dhall

Lines changed: 0 additions & 36 deletions
This file was deleted.

toodles.cabal

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ cabal-version: 1.12
44
--
55
-- see: https://github.com/sol/hpack
66
--
7-
-- hash: f1065a51b86ff48993a22be460338247dcf2d32b7beb90b72f0e4e23622d3f8c
7+
-- hash: f68cfaef2046d66fb1295333e3b53e62da19f337ca7e7d1e2019158db31b32cf
88

99
name: toodles
1010
version: 1.2.1
@@ -102,6 +102,7 @@ executable toodles
102102
, cmdargs ==0.10.20
103103
, directory ==1.3.1.5
104104
, extra ==1.6.13
105+
, filepath ==1.4.2
105106
, megaparsec ==6.5.0
106107
, process >=1.6.3.0
107108
, regex-posix ==0.95.2

0 commit comments

Comments
 (0)