summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--KeyRing.hs13
1 files changed, 9 insertions, 4 deletions
diff --git a/KeyRing.hs b/KeyRing.hs
index 85f2944..3765f42 100644
--- a/KeyRing.hs
+++ b/KeyRing.hs
@@ -84,7 +84,7 @@ import Data.ASN1.BinaryEncoding ( DER(..) )
84import Data.Time.Clock.POSIX ( getPOSIXTime ) 84import Data.Time.Clock.POSIX ( getPOSIXTime )
85import qualified Data.Map as Map 85import qualified Data.Map as Map
86import qualified Data.ByteString.Lazy as L ( unpack, pack, null, readFile, writeFile 86import qualified Data.ByteString.Lazy as L ( unpack, pack, null, readFile, writeFile
87 , ByteString, toChunks ) 87 , ByteString, toChunks, hGetContents, concat )
88import qualified Data.ByteString as S ( ByteString, unpack, splitAt, concat, cons, spanEnd, hGetContents, readFile) 88import qualified Data.ByteString as S ( ByteString, unpack, splitAt, concat, cons, spanEnd, hGetContents, readFile)
89import qualified Crypto.Types.PubKey.ECC as ECC 89import qualified Crypto.Types.PubKey.ECC as ECC
90import qualified Codec.Binary.Base32 as Base32 90import qualified Codec.Binary.Base32 as Base32
@@ -833,13 +833,18 @@ data InputFileContext = InputFileContext
833 , homepubPath :: FilePath 833 , homepubPath :: FilePath
834 } 834 }
835 835
836
837readInputFileS :: InputFileContext -> InputFile -> IO S.ByteString 836readInputFileS :: InputFileContext -> InputFile -> IO S.ByteString
838readInputFileS ctx (FileDesc fd) = fdToHandle fd >>= S.hGetContents 837readInputFileS ctx (FileDesc fd) = fdToHandle fd >>= S.hGetContents
839readInputFileS ctx inp = do 838readInputFileS ctx inp = do
840 let fname = resolveInputFile ctx inp 839 let fname = resolveInputFile ctx inp
841 fmap S.concat $ mapM S.readFile fname 840 fmap S.concat $ mapM S.readFile fname
842 841
842readInputFileL :: InputFileContext -> InputFile -> IO L.ByteString
843readInputFileL ctx (FileDesc fd) = fdToHandle fd >>= L.hGetContents
844readInputFileL ctx inp = do
845 let fname = resolveInputFile ctx inp
846 fmap L.concat $ mapM L.readFile fname
847
843cachedContents :: InputFileContext -> InputFile -> IO (IO S.ByteString) 848cachedContents :: InputFileContext -> InputFile -> IO (IO S.ByteString)
844cachedContents ctx fd = do 849cachedContents ctx fd = do
845 ref <- newIORef Nothing 850 ref <- newIORef Nothing
@@ -886,9 +891,9 @@ mergeHostFiles krd db ctx = do
886 files istyp = do 891 files istyp = do
887 (f,stream) <- Map.toList (kFiles krd) 892 (f,stream) <- Map.toList (kFiles krd)
888 guard (istyp $ typ stream) 893 guard (istyp $ typ stream)
889 resolveInputFile ctx f 894 return f
890 895
891 hostdbs0 <- mapM (fmap Hosts.decode . L.readFile) hns 896 hostdbs0 <- mapM (fmap Hosts.decode . readInputFileL ctx) hns
892 897
893 let gpgnames = map getHostnames $ Map.elems db 898 let gpgnames = map getHostnames $ Map.elems db
894 os = do 899 os = do