updateRootMirrorsAndKeys :: ServerEnv
                         -> StateComponent AcidState SecurityState
                         -> IO ()
updateRootMirrorsAndKeys env securityState = do
    mbRootMirrorsAndKeys <- loadRootMirrorsAndKeys env
    st <- queryState securityState GetSecurityState
    case mbRootMirrorsAndKeys of
      Just (root, mirrors, snapshotKey, timestampKey)
        | anyChange st root mirrors snapshotKey timestampKey
        -> do loginfo (serverVerbosity env) "Security files changed, updating"
              now <- getCurrentTime
              updateState securityState (SetRootMirrorsAndKeys
                                           root mirrors
                                           snapshotKey timestampKey
                                           now)
      _ -> loginfo (serverVerbosity env) "Security files unchanged"
  where
    anyChange SecurityState{ securityStateFiles = Nothing } _ _ _ _ = True
    anyChange SecurityState{ securityStateFiles = Just SecurityStateFiles{..} }
              root mirrors snapshotKey timestampKey =
        securityRoot         /= root
     || securityMirrors      /= mirrors
     || securitySnapshotKey  /= snapshotKey
     || securityTimestampKey /= timestampKey
updateRootMirrorsAndKeys :: ServerEnv
                         -> StateComponent AcidState SecurityState
                         -> IO ()
updateRootMirrorsAndKeys env securityState = do
    mbRootMirrorsAndKeys <- loadRootMirrorsAndKeys env
    st <- queryState securityState GetSecurityState
    case mbRootMirrorsAndKeys of
      Just (root, mirrors, snapshotKey, timestampKey)
        | anyChange st root mirrors snapshotKey timestampKey
        -> do loginfo (serverVerbosity env) "Security files changed, updating"
              now <- getCurrentTime
              updateState securityState (SetRootMirrorsAndKeys
                                           root mirrors
                                           snapshotKey timestampKey
                                           now)
      _ -> loginfo (serverVerbosity env) "Security files unchanged"
  where
    anyChange SecurityState{ securityStateFiles = Nothing } _ _ _ _ = True
    anyChange SecurityState{ securityStateFiles = Just SecurityStateFiles{..} }
              root mirrors snapshotKey timestampKey =
        securityRoot         /= root
     || securityMirrors      /= mirrors
     || securitySnapshotKey  /= snapshotKey
     || securityTimestampKey /= timestampKey
updateRootMirrorsAndKeys env securityState = do
    mbRootMirrorsAndKeys <- loadRootMirrorsAndKeys env
    st <- queryState securityState GetSecurityState
    case mbRootMirrorsAndKeys of
      Just (root, mirrors, snapshotKey, timestampKey)
        | anyChange st root mirrors snapshotKey timestampKey
        -> do loginfo (serverVerbosity env) "Security files changed, updating"
              now <- getCurrentTime
              updateState securityState (SetRootMirrorsAndKeys
                                           root mirrors
                                           snapshotKey timestampKey
                                           now)
      _ -> loginfo (serverVerbosity env) "Security files unchanged"
  where
    anyChange SecurityState{ securityStateFiles = Nothing } _ _ _ _ = True
    anyChange SecurityState{ securityStateFiles = Just SecurityStateFiles{..} }
              root mirrors snapshotKey timestampKey =
        securityRoot         /= root
     || securityMirrors      /= mirrors
     || securitySnapshotKey  /= snapshotKey
     || securityTimestampKey /= timestampKey