diff options
-rw-r--r-- | KeyRing.hs | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -84,7 +84,7 @@ import Data.ASN1.BinaryEncoding ( DER(..) ) | |||
84 | import Data.Time.Clock.POSIX ( getPOSIXTime ) | 84 | import Data.Time.Clock.POSIX ( getPOSIXTime ) |
85 | import qualified Data.Map as Map | 85 | import qualified Data.Map as Map |
86 | import qualified Data.ByteString.Lazy as L ( unpack, pack, null, readFile, writeFile | 86 | import qualified Data.ByteString.Lazy as L ( unpack, pack, null, readFile, writeFile |
87 | , ByteString, toChunks ) | 87 | , ByteString, toChunks, hGetContents, concat ) |
88 | import qualified Data.ByteString as S ( ByteString, unpack, splitAt, concat, cons, spanEnd, hGetContents, readFile) | 88 | import qualified Data.ByteString as S ( ByteString, unpack, splitAt, concat, cons, spanEnd, hGetContents, readFile) |
89 | import qualified Crypto.Types.PubKey.ECC as ECC | 89 | import qualified Crypto.Types.PubKey.ECC as ECC |
90 | import qualified Codec.Binary.Base32 as Base32 | 90 | import qualified Codec.Binary.Base32 as Base32 |
@@ -833,13 +833,18 @@ data InputFileContext = InputFileContext | |||
833 | , homepubPath :: FilePath | 833 | , homepubPath :: FilePath |
834 | } | 834 | } |
835 | 835 | ||
836 | |||
837 | readInputFileS :: InputFileContext -> InputFile -> IO S.ByteString | 836 | readInputFileS :: InputFileContext -> InputFile -> IO S.ByteString |
838 | readInputFileS ctx (FileDesc fd) = fdToHandle fd >>= S.hGetContents | 837 | readInputFileS ctx (FileDesc fd) = fdToHandle fd >>= S.hGetContents |
839 | readInputFileS ctx inp = do | 838 | readInputFileS 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 | ||
842 | readInputFileL :: InputFileContext -> InputFile -> IO L.ByteString | ||
843 | readInputFileL ctx (FileDesc fd) = fdToHandle fd >>= L.hGetContents | ||
844 | readInputFileL ctx inp = do | ||
845 | let fname = resolveInputFile ctx inp | ||
846 | fmap L.concat $ mapM L.readFile fname | ||
847 | |||
843 | cachedContents :: InputFileContext -> InputFile -> IO (IO S.ByteString) | 848 | cachedContents :: InputFileContext -> InputFile -> IO (IO S.ByteString) |
844 | cachedContents ctx fd = do | 849 | cachedContents 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 |