diff --git a/platform/platform-impl/src/com/intellij/diagnostic/WindowsDefenderChecker.java b/platform/platform-impl/src/com/intellij/diagnostic/WindowsDefenderChecker.java index 91acae0e881f..c066f229fdbe 100644 --- a/platform/platform-impl/src/com/intellij/diagnostic/WindowsDefenderChecker.java +++ b/platform/platform-impl/src/com/intellij/diagnostic/WindowsDefenderChecker.java @@ -34,6 +34,7 @@ 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; @@ -89,18 +90,19 @@ public class WindowsDefenderChecker { @ApiStatus.Internal @RequiresBackgroundThread - final @Nullable Boolean isAlreadyProcessed(@NotNull Project project) { + final boolean isAlreadyProcessed(@NotNull Project project, Consumer<@Nullable Boolean> notifyAction) { var projectPath = getProjectPath(project); if (projectPath != null && myProjectPaths.containsKey(projectPath)) { while (!project.isDisposed() && myProjectPaths.get(projectPath) == null) TimeoutUtil.sleep(100); - var success = myProjectPaths.remove(projectPath); + Boolean success = myProjectPaths.remove(projectPath); if (success == Boolean.TRUE) { PropertiesComponent.getInstance(project).setValue(IGNORE_STATUS_CHECK, true); } - return success; + notifyAction.accept(success); + return true; } - return null; + return false; } private static @Nullable Path getProjectPath(Project project) { diff --git a/platform/platform-impl/src/com/intellij/diagnostic/WindowsDefenderCheckerActivity.kt b/platform/platform-impl/src/com/intellij/diagnostic/WindowsDefenderCheckerActivity.kt index 57b710db6bb7..96bd1053cb3c 100644 --- a/platform/platform-impl/src/com/intellij/diagnostic/WindowsDefenderCheckerActivity.kt +++ b/platform/platform-impl/src/com/intellij/diagnostic/WindowsDefenderCheckerActivity.kt @@ -44,19 +44,19 @@ internal class WindowsDefenderCheckerActivity : ProjectActivity { WindowsDefenderStatisticsCollector.configured(project, success) - // otherwise, the notification will be shown on project opening + //otherwise notification will be sent after project opening if (project != null) { notify(project, success) } } } - private fun notify(project: Project, success: Boolean) { + private fun notify(project: Project, success: Boolean?) { if (success == true) { Notification("WindowsDefender", DiagnosticBundle.message("defender.config.success"), NotificationType.INFORMATION) .notify(project) } - else { + else if ( success == false){ Notification("WindowsDefender", DiagnosticBundle.message("defender.config.failed"), NotificationType.ERROR) .addAction(ShowLogAction.notificationAction()) .notify(project) @@ -73,20 +73,13 @@ internal class WindowsDefenderCheckerActivity : ProjectActivity { override suspend fun execute(project: Project) { val checker = serviceAsync() - - if (checker.isStatusCheckIgnored(project)) { + val alreadyProcessed = checker.isAlreadyProcessed(project) { success: Boolean? -> notify(project, success) } + if (checker.isStatusCheckIgnored(project) || alreadyProcessed) { LOG.info("status check is disabled") WindowsDefenderStatisticsCollector.protectionCheckSkipped(project) return } - val alreadyProcessed = checker.isAlreadyProcessed(project) - if (alreadyProcessed != null) { - notify(project, success = alreadyProcessed) - LOG.info("requested from the \"trust project\" dialog; success=${alreadyProcessed}") - return - } - @OptIn(IntellijInternalApi::class, DelicateCoroutinesApi::class) computeDetached { checkDefenderStatus(project, checker)