Skip to content

Commit

Permalink
data dir checks to fix installation with scarf
Browse files Browse the repository at this point in the history
  • Loading branch information
aviaviavi committed Jul 12, 2019
1 parent ffcdf4d commit b938dc0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 40 deletions.
22 changes: 20 additions & 2 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,34 @@ import Paths_toodles
import Server
import Types

import Control.Monad (when)
import Data.IORef (newIORef)
import Data.Maybe (fromMaybe)
import qualified Data.Text as T (unpack)
import Network.Wai.Handler.Warp (run)
import System.Directory
import System.Environment
import System.FilePath.Posix
import Text.Printf (printf)

main :: IO ()
main = do
dataDir <- getDataDir
licenseRead <- readLicense (dataDir ++ "/toodles-license-public-key.pem") "/etc/toodles/license.json"
dataDirLocal <- (return . takeDirectory) =<< getExecutablePath
dataDirBuilt <- getDataDir
useBinaryLocalDataDir <- doesDirectoryExist $ dataDirLocal <> "/web"
useBuiltDataDir <- doesDirectoryExist $ dataDirBuilt <> "/web"
when
(not useBuiltDataDir && not useBuiltDataDir)
(fail
"Couldn't initialize toodles, no valid data directory found. Please file a bug on Github.")
let dataDir =
if useBinaryLocalDataDir
then dataDirLocal
else dataDirBuilt
licenseRead <-
readLicense
(dataDir ++ "/toodles-license-public-key.pem")
"/etc/toodles/license.json"
let license = (either (BadLicense) (id) licenseRead)
userArgs <- toodlesArgs >>= setAbsolutePath
case userArgs of
Expand Down
3 changes: 2 additions & 1 deletion package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: toodles
version: 1.2.1
version: 1.2.2
github: "aviaviavi/toodles"
license: MIT
author: "Avi Press"
Expand Down Expand Up @@ -92,6 +92,7 @@ executables:
- cmdargs ==0.10.20
- directory ==1.3.1.5
- extra ==1.6.13
- filepath ==1.4.2
- megaparsec ==6.5.0
- process >=1.6.3.0
- regex-posix ==0.95.2
Expand Down
36 changes: 0 additions & 36 deletions toodles-scarf.dhall

This file was deleted.

3 changes: 2 additions & 1 deletion toodles.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cabal-version: 1.12
--
-- see: https://github.com/sol/hpack
--
-- hash: f1065a51b86ff48993a22be460338247dcf2d32b7beb90b72f0e4e23622d3f8c
-- hash: f68cfaef2046d66fb1295333e3b53e62da19f337ca7e7d1e2019158db31b32cf

name: toodles
version: 1.2.1
Expand Down Expand Up @@ -102,6 +102,7 @@ executable toodles
, cmdargs ==0.10.20
, directory ==1.3.1.5
, extra ==1.6.13
, filepath ==1.4.2
, megaparsec ==6.5.0
, process >=1.6.3.0
, regex-posix ==0.95.2
Expand Down

0 comments on commit b938dc0

Please sign in to comment.