Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Przemyslaw Kaminski
haskell-gargantext
Commits
fcfb2cd8
Commit
fcfb2cd8
authored
Feb 13, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] repo file snapshots.
parent
9af716d1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
11 deletions
+21
-11
Settings.hs
src/Gargantext/API/Settings.hs
+21
-11
No files found.
src/Gargantext/API/Settings.hs
View file @
fcfb2cd8
...
...
@@ -38,7 +38,7 @@ import Network.HTTP.Client.TLS (newTlsManager)
import
Data.Aeson
import
Data.Maybe
(
fromMaybe
)
import
Data.Either
(
either
)
import
Data.JsonState
import
Data.JsonState
(
mkSaveState
)
import
Data.Text
import
Data.Text.Encoding
(
encodeUtf8
)
import
Data.Time.Units
...
...
@@ -169,14 +169,21 @@ repoSnapshot = "repo.json"
readRepo
::
IO
(
MVar
NgramsRepo
)
readRepo
=
do
repoExists
<-
doesFileExist
repoSnapshot
-- | Does file exist ? :: Bool
repoFile
<-
doesFileExist
repoSnapshot
-- | Is file not empty ? :: Bool
repoExists
<-
if
repoFile
then
(
>
0
)
<$>
getFileSize
repoSnapshot
else
pure
repoFile
newMVar
=<<
if
repoExists
then
do
e_repo
<-
eitherDecodeFileStrict
repoSnapshot
repo
<-
either
fail
pure
e_repo
repo
<-
either
fail
pure
e_repo
let
archive
=
repoSnapshot
<>
".v"
<>
show
(
repo
^.
r_version
)
rename
File
repoSnapshot
archive
copy
File
repoSnapshot
archive
pure
repo
else
pure
initMockRepo
...
...
@@ -192,13 +199,16 @@ newEnv port file = do
settings
<-
pure
(
devSettings
&
appPort
.~
port
)
-- TODO read from 'file'
when
(
port
/=
settings
^.
appPort
)
$
panic
"TODO: conflicting settings of port"
self_url
<-
parseBaseUrl
$
"http://0.0.0.0:"
<>
show
port
param
<-
databaseParameters
file
conn
<-
connect
param
repo_var
<-
readRepo
repo_saver
<-
mkRepoSaver
repo_var
param
<-
databaseParameters
file
conn
<-
connect
param
repo_var
<-
readRepo
repo_saver
<-
mkRepoSaver
repo_var
scrapers_env
<-
newJobEnv
defaultSettings
manager
logger
<-
newStderrLoggerSet
defaultBufSize
pure
$
Env
{
_env_settings
=
settings
,
_env_logger
=
logger
...
...
@@ -229,9 +239,9 @@ instance HasRepoSaver DevEnv where
newDevEnvWith
::
FilePath
->
IO
DevEnv
newDevEnvWith
file
=
do
param
<-
databaseParameters
file
conn
<-
connect
param
repo_var
<-
newMVar
initMockRepo
param
<-
databaseParameters
file
conn
<-
connect
param
repo_var
<-
newMVar
initMockRepo
repo_saver
<-
mkRepoSaver
repo_var
pure
$
DevEnv
{
_dev_env_conn
=
conn
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment