Commit ff6e2e1e authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FIX] Ngrams repo missing directory.

parent 6890ae68
...@@ -178,14 +178,18 @@ data MockEnv = MockEnv ...@@ -178,14 +178,18 @@ data MockEnv = MockEnv
makeLenses ''MockEnv makeLenses ''MockEnv
-- | TODO add this path in Settings -- | TODO add this path in Settings
repoDir :: FilePath
repoDir = "repos"
repoSnapshot :: FilePath repoSnapshot :: FilePath
repoSnapshot = "repo.json" repoSnapshot = repoDir <> "/repo.json"
-- | TODO add hard coded file in Settings -- | TODO add hard coded file in Settings
-- This assumes we own the lock on repoSnapshot. -- This assumes we own the lock on repoSnapshot.
repoSaverAction :: ToJSON a => a -> IO () repoSaverAction :: ToJSON a => a -> IO ()
repoSaverAction a = do repoSaverAction a = do
withTempFile "." "tmp-repo.json" $ \fp h -> do withTempFile "repos" "tmp-repo.json" $ \fp h -> do
-- printDebug "repoSaverAction" fp -- printDebug "repoSaverAction" fp
L.hPut h $ encode a L.hPut h $ encode a
hClose h hClose h
...@@ -210,6 +214,8 @@ mkRepoSaver repo_var = mkDebounce settings ...@@ -210,6 +214,8 @@ mkRepoSaver repo_var = mkDebounce settings
readRepoEnv :: IO RepoEnv readRepoEnv :: IO RepoEnv
readRepoEnv = do readRepoEnv = do
-- Does file exist ? :: Bool -- Does file exist ? :: Bool
_repoDir <- doesDirectoryExist True repoDir
repoFile <- doesFileExist repoSnapshot repoFile <- doesFileExist repoSnapshot
-- Is file not empty ? :: Bool -- Is file not empty ? :: Bool
...@@ -230,7 +236,7 @@ readRepoEnv = do ...@@ -230,7 +236,7 @@ readRepoEnv = do
pure repo pure repo
else else
pure initRepo pure initRepo
-- TODO save in DB here
saver <- mkRepoSaver mvar saver <- mkRepoSaver mvar
pure $ RepoEnv { _renv_var = mvar, _renv_saver = saver, _renv_lock = lock } pure $ RepoEnv { _renv_var = mvar, _renv_saver = saver, _renv_lock = lock }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment