From 74aae2e664f4c7132947a415a3fb2a08bf233fb4 Mon Sep 17 00:00:00 2001 From: joe Date: Tue, 23 Jun 2015 14:32:33 -0400 Subject: Now recognizes deleted packets as file changes requring writes. --- KeyRing.hs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/KeyRing.hs b/KeyRing.hs index b885805..1ab819a 100644 --- a/KeyRing.hs +++ b/KeyRing.hs @@ -1827,12 +1827,13 @@ isauth rt keydata = dont_have keydata && maybe False (`has_good_sig` keydata) wk return $ keyPacket elm writeRingKeys :: KeyRingOperation -> KeyRingRuntime -> Map.Map InputFile Message + -> [(FilePath,KikiReportAction)] {- -> KeyDB -> Maybe Packet -> FilePath -> FilePath -} -> IO (KikiCondition [(FilePath,KikiReportAction)]) -writeRingKeys krd rt {- db wk secring pubring -} unspilled = do +writeRingKeys krd rt {- db wk secring pubring -} unspilled report_manips = do let isring (KeyRingFile {}) = True isring _ = False db = rtKeyDB rt @@ -1879,7 +1880,12 @@ writeRingKeys krd rt {- db wk secring pubring -} unspilled = do _ -> flattenTop f only_public d new_packets = filter isnew x where isnew p = isNothing (Map.lookup (resolveForReport Nothing f0) $ locations p) - guard (not $ null new_packets) + -- TODO: We depend on an exact string match between the reported + -- file origin of the deleted packet and the path of the file we are + -- writing. Verify that this is a safe assumption. + isdeleted (f',DeletedPacket _) = f'==f + isdeleted _ = False + guard (not (null new_packets) || any isdeleted report_manips) return ((f0,isMutable stream),(new_packets,x)) let (towrites,report) = (\f -> foldl f ([],[]) s) $ \(ws,report) ((f,mutable),(new_packets,x)) -> @@ -2426,7 +2432,7 @@ runKeyRing operation = do r <- writeWalletKeys operation (rtKeyDB rt) (fmap packet wk) try' r $ \report_wallets -> do - r <- writeRingKeys operation rt unspilled + r <- writeRingKeys operation rt unspilled report_manips try' r $ \report_rings -> do r <- writePEMKeys decrypt (rtKeyDB rt) exports -- cgit v1.2.3