From f82b12dc1701d311d6d5a3c9fbcab762e9c278af Mon Sep 17 00:00:00 2001 From: joe Date: Tue, 30 Aug 2016 02:28:41 -0400 Subject: Switched cache update to lib/Keyring.hs interface. --- lib/KeyRing.hs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'lib/KeyRing.hs') diff --git a/lib/KeyRing.hs b/lib/KeyRing.hs index 5cd5c71..5953f12 100644 --- a/lib/KeyRing.hs +++ b/lib/KeyRing.hs @@ -2395,12 +2395,16 @@ initializeMissingPEMFiles :: , [(FilePath,KikiReportAction)])) initializeMissingPEMFiles operation ctx grip mwk transcode db = do let decrypt = transcode (Unencrypted,S2K 100 "") + + -- nonexistants - files missing from disk. nonexistents <- filterM (fmap not . doesFileExist . fst) $ do (f,t) <- Map.toList (opFiles operation) f <- resolveInputFile ctx f return (f,t) + -- missing - mutable files not in the keyring and not on disk + -- notmissing - mutable keys in the keyring, but not on disk let (missing,notmissing) = partition (\(_,_,ns,_)->null (ns >>= snd)) $ do (fname,stream) <- nonexistents let mutableTag @@ -2458,12 +2462,20 @@ initializeMissingPEMFiles operation ctx grip mwk transcode db = do try v $ \(db,import_rs) -> do -- generateInternals - let internals = mapMaybe getParams nonexistents + let internals = mapMaybe getParams $ do + (f,stream) <- nonexistents + usage <- take 1 $ mapMaybe usageFromFilter [fill stream,spill stream] + let (topspec,subspec) = parseSpec (fromMaybe "" grip) usage + guard $ null $ do + (kk,kd) <- filterMatches topspec $ Map.toList db + subkeysForExport subspec kd + return (f,stream) where getParams (fname,stream) = case initializer stream of Internal p -> do _ <- internalInitializer stream - Just (p, stream) + Just $ Right (p, stream) + WarnMissing warning -> Just $ Left warning _ -> Nothing internalInitializer StreamInfo @@ -2471,7 +2483,8 @@ initializeMissingPEMFiles operation ctx grip mwk transcode db = do , spill = KF_Match tag } = Just tag internalInitializer _ = Nothing - v <- generateInternals transcode mwk db internals + mapM_ (hPutStrLn stderr) (lefts internals) + v <- generateInternals transcode mwk db (rights internals) try v $ \(db,internals_rs) -> do @@ -2656,6 +2669,7 @@ runKeyRing operation = do secring <- return Nothing pubring <- return Nothing lks <- forM tolocks $ \f -> do + createDirectoryIfMissing True $ takeDirectory f lk <- dotlock_create f 0 v <- flip (maybe $ return Nothing) lk $ \lk -> do e <- dotlock_take lk (-1) -- cgit v1.2.3