From 26b4148a6c14d868df624c1a1144e556e68e76cd Mon Sep 17 00:00:00 2001 From: joe Date: Tue, 29 Apr 2014 19:16:37 -0400 Subject: mergeHostFiles now accepts non-filepath inputs. --- KeyRing.hs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'KeyRing.hs') 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(..) ) import Data.Time.Clock.POSIX ( getPOSIXTime ) import qualified Data.Map as Map import qualified Data.ByteString.Lazy as L ( unpack, pack, null, readFile, writeFile - , ByteString, toChunks ) + , ByteString, toChunks, hGetContents, concat ) import qualified Data.ByteString as S ( ByteString, unpack, splitAt, concat, cons, spanEnd, hGetContents, readFile) import qualified Crypto.Types.PubKey.ECC as ECC import qualified Codec.Binary.Base32 as Base32 @@ -833,13 +833,18 @@ data InputFileContext = InputFileContext , homepubPath :: FilePath } - readInputFileS :: InputFileContext -> InputFile -> IO S.ByteString readInputFileS ctx (FileDesc fd) = fdToHandle fd >>= S.hGetContents readInputFileS ctx inp = do let fname = resolveInputFile ctx inp fmap S.concat $ mapM S.readFile fname +readInputFileL :: InputFileContext -> InputFile -> IO L.ByteString +readInputFileL ctx (FileDesc fd) = fdToHandle fd >>= L.hGetContents +readInputFileL ctx inp = do + let fname = resolveInputFile ctx inp + fmap L.concat $ mapM L.readFile fname + cachedContents :: InputFileContext -> InputFile -> IO (IO S.ByteString) cachedContents ctx fd = do ref <- newIORef Nothing @@ -886,9 +891,9 @@ mergeHostFiles krd db ctx = do files istyp = do (f,stream) <- Map.toList (kFiles krd) guard (istyp $ typ stream) - resolveInputFile ctx f + return f - hostdbs0 <- mapM (fmap Hosts.decode . L.readFile) hns + hostdbs0 <- mapM (fmap Hosts.decode . readInputFileL ctx) hns let gpgnames = map getHostnames $ Map.elems db os = do -- cgit v1.2.3