on master help sign in
read files strictly in "Obelisk.Migration".

To avoid "too many open files" error.

commit288eab4864b3a15b575ede81ac7277ae1c08deda authorRobert Klotzner <robert.klotzner@gmx.at> dateThu 12 Jul 2018, 17:14 (8 years ago) parent64e0fca
1 file changed+4−3
lib/migration/src/Obelisk/Migration.hs+4−3
lib/migration/src/Obelisk/Migration.hs+4−3
@@ -17,6 +17,7 @@ import Data.Set (Set)
1717import qualified Data.Set as Set
1818import Data.Text (Text)
1919import qualified Data.Text as T
20+import qualified Data.Text.IO as T
2021import System.Directory
2122import System.FilePath
2223
@@ -66,10 +67,10 @@ instance Exception MissingEdgeInActionMap
6667instance Exception NonLinearGraph
6768
6869class Action action where
69− parseEdgeMeta :: String -> action
70+ parseEdgeMeta :: Text -> action
7071
7172instance Action Text where
72− parseEdgeMeta = T.pack
73+ parseEdgeMeta = id
7374
7475-- | Get the directed-acylic graph of migration
7576-- TODO: Consider calling getDag only when reading the graph for efficiency.
@@ -95,7 +96,7 @@ readGraph root name = doesDirectoryExist root >>= \case
9596 let f = root </> (T.unpack $ v1 <> "-" <> v2) </> T.unpack graph
9697 doesFileExist f >>= \case
9798 True -> do
98− c <- readFile f >>= pure . parseEdgeMeta
99+ c <- parseEdgeMeta <$> T.readFile f
99100 return $ Just c
100101 False -> do
101102 return Nothing