summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2014-04-20 13:36:50 -0400
committerjoe <joe@jerkface.net>2014-04-20 13:36:50 -0400
commit5d281f525da310b0d2b5039232f25d6211a76ae6 (patch)
tree17502d6e9de8e4d042d37d8d6f2f5a871c15035f
parent6a30393193e3df562b605a7fcd01d56582a8f2ff (diff)
minor refactor
-rw-r--r--KeyRing.hs29
1 files changed, 15 insertions, 14 deletions
diff --git a/KeyRing.hs b/KeyRing.hs
index 36477c0..49ddec4 100644
--- a/KeyRing.hs
+++ b/KeyRing.hs
@@ -1286,19 +1286,20 @@ runKeyRing operation = do
1286 then return $ KikiResult (FailedToLock failed_locks) [] 1286 then return $ KikiResult (FailedToLock failed_locks) []
1287 else do 1287 else do
1288 1288
1289 pws <- 1289 -- memoizing decrypter
1290 -- TODO: head will throw an exception if a File Descriptor operation 1290 decrypt <- do
1291 -- file is present. We probably should change OriginMap to use InputFile 1291 pws <-
1292 -- instead of FilePath. 1292 -- TODO: head will throw an exception if a File Descriptor operation
1293 Traversable.mapM (cachedContents secring pubring . fromJust . pwfile . snd) 1293 -- file is present. We probably should change OriginMap to use InputFile
1294 (Map.mapKeys (head . resolveInputFile secring pubring) 1294 -- instead of FilePath.
1295 $ Map.filter (isJust . pwfile . snd) $ kFiles operation) 1295 Traversable.mapM (cachedContents secring pubring . fromJust . pwfile . snd)
1296 1296 (Map.mapKeys (head . resolveInputFile secring pubring)
1297 unkeysRef <- newIORef Map.empty 1297 $ Map.filter (isJust . pwfile . snd) $ kFiles operation)
1298 unkeysRef <- newIORef Map.empty
1299 return $ doDecrypt unkeysRef pws
1298 1300
1299 -- merge all keyrings, PEM files, and wallets 1301 -- merge all keyrings, PEM files, and wallets
1300 bresult <- buildKeyDB (doDecrypt unkeysRef pws) secring pubring grip0 operation 1302 bresult <- buildKeyDB decrypt secring pubring grip0 operation
1301
1302 try' bresult $ \((db,grip,wk),report_imports) -> do 1303 try' bresult $ \((db,grip,wk),report_imports) -> do
1303 1304
1304 nonexistents <- 1305 nonexistents <-
@@ -1348,7 +1349,7 @@ runKeyRing operation = do
1348 ExitFailure num -> return (tup,FailedExternal num) 1349 ExitFailure num -> return (tup,FailedExternal num)
1349 ExitSuccess -> return (tup,ExternallyGeneratedFile) 1350 ExitSuccess -> return (tup,ExternallyGeneratedFile)
1350 1351
1351 v <- foldM (importPEMKey $ doDecrypt unkeysRef pws) 1352 v <- foldM (importPEMKey decrypt)
1352 (KikiSuccess (db,[])) $ do 1353 (KikiSuccess (db,[])) $ do
1353 ((f,subspec,ms,cmd),r) <- rs 1354 ((f,subspec,ms,cmd),r) <- rs
1354 guard $ case r of 1355 guard $ case r of
@@ -1371,7 +1372,7 @@ runKeyRing operation = do
1371 try' externals_ret $ \(db,report_externals) -> do 1372 try' externals_ret $ \(db,report_externals) -> do
1372 1373
1373 1374
1374 r <- performManipulations (doDecrypt unkeysRef pws) 1375 r <- performManipulations decrypt
1375 operation 1376 operation
1376 rt 1377 rt
1377 wk 1378 wk
@@ -1384,7 +1385,7 @@ runKeyRing operation = do
1384 r <- writeRingKeys operation rt -- db wk secring pubring 1385 r <- writeRingKeys operation rt -- db wk secring pubring
1385 try' r $ \report_rings -> do 1386 try' r $ \report_rings -> do
1386 1387
1387 r <- writePEMKeys (doDecrypt unkeysRef pws) db exports 1388 r <- writePEMKeys decrypt db exports
1388 try' r $ \report_pems -> do 1389 try' r $ \report_pems -> do
1389 1390
1390 return $ KikiResult (KikiSuccess rt) 1391 return $ KikiResult (KikiSuccess rt)