From 2973c316a8aa03f0f06b9765815cc78a51e98546 Mon Sep 17 00:00:00 2001 From: Keagan McClelland Date: Fri, 12 Mar 2021 10:59:09 -0700 Subject: [PATCH] catches if either file doesn't exist and runs the sync if so (#245) --- agent/src/Lib/Synchronizers.hs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/agent/src/Lib/Synchronizers.hs b/agent/src/Lib/Synchronizers.hs index 6716f2c44..5530ba513 100644 --- a/agent/src/Lib/Synchronizers.hs +++ b/agent/src/Lib/Synchronizers.hs @@ -602,9 +602,17 @@ syncDropCertificateUniqueness = SyncOp "Eliminate OpenSSL unique_subject=yes" ch uni = "unique_subject = no\n" check = do base <- asks $ appFilesystemBase . appSettings - contentsRoot <- liftIO . BS.readFile . toS $ (rootCaDirectory <> "index.txt.attr") `relativeTo` base - contentsInt <- liftIO . BS.readFile . toS $ (intermediateCaDirectory <> "index.txt.attr") `relativeTo` base - pure $ uni /= contentsRoot || uni /= contentsInt + contentsRoot <- + liftIO + $ (fmap Just . BS.readFile . toS $ (rootCaDirectory <> "index.txt.attr") `relativeTo` base) + `catch` \(e :: IOException) -> if isDoesNotExistError e then pure Nothing else throwIO e + contentsInt <- + liftIO + $ (fmap Just . BS.readFile . toS $ (intermediateCaDirectory <> "index.txt.attr") `relativeTo` base) + `catch` \(e :: IOException) -> if isDoesNotExistError e then pure Nothing else throwIO e + case (contentsRoot, contentsInt) of + (Just root, Just int) -> pure $ uni /= root || uni /= int + _ -> pure True migrate = do base <- asks $ appFilesystemBase . appSettings liftIO $ BS.writeFile (toS $ (rootCaDirectory <> "index.txt.attr") `relativeTo` base) uni