summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2014-04-30 14:43:43 -0400
committerjoe <joe@jerkface.net>2014-04-30 14:43:43 -0400
commitc7a29035029180c9e55aa613f50dbd42c26661d2 (patch)
tree927e8492b7e0b8ae718fecd593765757d745099d
parente1db68cc5f63b7fb05cc55dfdd1895320f7062e1 (diff)
writeKeyRings now uses writeInputFileL instead of L.writeFile
-rw-r--r--KeyRing.hs16
1 files changed, 11 insertions, 5 deletions
diff --git a/KeyRing.hs b/KeyRing.hs
index 0cdb36f..c6b592f 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, hGetContents, concat ) 87 , ByteString, toChunks, hGetContents, hPut, 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
@@ -847,6 +847,12 @@ readInputFileL ctx inp = do
847 fmap L.concat $ mapM L.readFile fname 847 fmap L.concat $ mapM L.readFile fname
848 848
849 849
850writeInputFileL ctx (FileDesc fd) bs = fdToHandle fd >>= (`L.hPut` bs)
851writeInputFileL ctx inp bs = do
852 let fname = resolveInputFile ctx inp
853 mapM_ (`L.writeFile` bs) fname
854
855
850getInputFileTime :: InputFileContext -> InputFile -> IO CTime 856getInputFileTime :: InputFileContext -> InputFile -> IO CTime
851getInputFileTime ctx (FileDesc fd) = do 857getInputFileTime ctx (FileDesc fd) = do
852 handleIO_ (error $ "&"++show fd++": modificaiton time?") $ 858 handleIO_ (error $ "&"++show fd++": modificaiton time?") $
@@ -1432,22 +1438,22 @@ writeRingKeys krd rt {- db wk secring pubring -} = do
1432 new_packets = filter isnew x 1438 new_packets = filter isnew x
1433 where isnew p = isNothing (Map.lookup f $ locations p) 1439 where isnew p = isNothing (Map.lookup f $ locations p)
1434 guard (not $ null new_packets) 1440 guard (not $ null new_packets)
1435 return ((f,isMutable stream),(new_packets,x)) 1441 return ((f0,isMutable stream),(new_packets,x))
1436 let (towrites,report) = (\f -> foldl f ([],[]) s) $ 1442 let (towrites,report) = (\f -> foldl f ([],[]) s) $
1437 \(ws,report) ((f,mutable),(new_packets,x)) -> 1443 \(ws,report) ((f,mutable),(new_packets,x)) ->
1438 if mutable 1444 if mutable
1439 then 1445 then
1440 let rs = flip map new_packets 1446 let rs = flip map new_packets
1441 $ \c -> (f, NewPacket $ showPacket (packet c)) 1447 $ \c -> (concat $ resolveInputFile ctx f, NewPacket $ showPacket (packet c))
1442 in (ws++[(f,x)],report++rs) 1448 in (ws++[(f,x)],report++rs)
1443 else 1449 else
1444 let rs = flip map new_packets 1450 let rs = flip map new_packets
1445 $ \c -> (f,MissingPacket (showPacket (packet c))) 1451 $ \c -> (concat $ resolveInputFile ctx f,MissingPacket (showPacket (packet c)))
1446 in (ws,report++rs) 1452 in (ws,report++rs)
1447 forM_ towrites $ \(f,x) -> do 1453 forM_ towrites $ \(f,x) -> do
1448 let m = Message $ map packet x 1454 let m = Message $ map packet x
1449 -- warn $ "writing "++f 1455 -- warn $ "writing "++f
1450 L.writeFile f (encode m) 1456 writeInputFileL ctx f (encode m)
1451 return $ KikiSuccess report 1457 return $ KikiSuccess report
1452 1458
1453 1459