From 139940624460d731bb84b344b69a3663f04a8ba2 Mon Sep 17 00:00:00 2001 From: Vera Petrenkova Date: Mon, 25 Nov 2024 12:29:03 +0100 Subject: [PATCH] Revert "IJPL-165257 Show windows defender notification after project opening" This reverts commit a0d2bb2f8fa84a377b324ee6e1095445866dff57. GitOrigin-RevId: a08f6730f0828250ccf388b74a66eb6705874296 --- .../diagnostic/WindowsDefenderChecker.java | 9 ++----- .../WindowsDefenderCheckerActivity.kt | 26 +++++++------------ 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/diagnostic/WindowsDefenderChecker.java b/platform/platform-impl/src/com/intellij/diagnostic/WindowsDefenderChecker.java index 3d28735ac9b5..86181e5a91d5 100644 --- a/platform/platform-impl/src/com/intellij/diagnostic/WindowsDefenderChecker.java +++ b/platform/platform-impl/src/com/intellij/diagnostic/WindowsDefenderChecker.java @@ -34,7 +34,6 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Path; import java.util.*; import java.util.concurrent.TimeUnit; -import java.util.function.Consumer; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -90,17 +89,13 @@ public class WindowsDefenderChecker { @ApiStatus.Internal @RequiresBackgroundThread - final boolean isAlreadyProcessed(@NotNull Project project, Consumer notifyAction) { + final boolean isAlreadyProcessed(@NotNull Project project) { var projectPath = getProjectPath(project); if (projectPath != null && myProjectPaths.containsKey(projectPath)) { while (!project.isDisposed() && myProjectPaths.get(projectPath) == null) TimeoutUtil.sleep(100); - Boolean success = myProjectPaths.remove(projectPath); - if (success == Boolean.TRUE) { + if (myProjectPaths.remove(projectPath) == Boolean.TRUE) { PropertiesComponent.getInstance(project).setValue(IGNORE_STATUS_CHECK, true); } - if (success != null) { - notifyAction.accept(success); - } return true; } diff --git a/platform/platform-impl/src/com/intellij/diagnostic/WindowsDefenderCheckerActivity.kt b/platform/platform-impl/src/com/intellij/diagnostic/WindowsDefenderCheckerActivity.kt index 4f056443163c..e02bc30011e1 100644 --- a/platform/platform-impl/src/com/intellij/diagnostic/WindowsDefenderCheckerActivity.kt +++ b/platform/platform-impl/src/com/intellij/diagnostic/WindowsDefenderCheckerActivity.kt @@ -44,20 +44,15 @@ internal class WindowsDefenderCheckerActivity : ProjectActivity { WindowsDefenderStatisticsCollector.configured(project, success) - if (project == null) return@launch //notification will be sent after project opening - notify(project, success) - } - } - - private fun notify(project: Project, success: Boolean) { - if (success) { - Notification("WindowsDefender", DiagnosticBundle.message("defender.config.success"), NotificationType.INFORMATION) - .notify(project) - } - else { - Notification("WindowsDefender", DiagnosticBundle.message("defender.config.failed"), NotificationType.ERROR) - .addAction(ShowLogAction.notificationAction()) - .notify(project) + if (success) { + Notification("WindowsDefender", DiagnosticBundle.message("defender.config.success"), NotificationType.INFORMATION) + .notify(project) + } + else { + Notification("WindowsDefender", DiagnosticBundle.message("defender.config.failed"), NotificationType.ERROR) + .addAction(ShowLogAction.notificationAction()) + .notify(project) + } } } } @@ -71,8 +66,7 @@ internal class WindowsDefenderCheckerActivity : ProjectActivity { override suspend fun execute(project: Project) { val checker = serviceAsync() - val alreadyProcessed = checker.isAlreadyProcessed(project) { success: Boolean -> notify(project, success) } - if (checker.isStatusCheckIgnored(project) || alreadyProcessed) { + if (checker.isStatusCheckIgnored(project) || checker.isAlreadyProcessed(project)) { LOG.info("status check is disabled") WindowsDefenderStatisticsCollector.protectionCheckSkipped(project) return