🎨 Support one-click addition of Microsoft Defender exclusions https://github.com/siyuan-note/siyuan/issues/13650

This commit is contained in:
Daniel 2024-12-29 10:35:55 +08:00
parent b3f55ac3b4
commit 203dbfa35a
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -26,6 +26,7 @@ import (
"path/filepath" "path/filepath"
"runtime" "runtime"
"strings" "strings"
"sync"
"syscall" "syscall"
"github.com/88250/gulu" "github.com/88250/gulu"
@ -34,7 +35,12 @@ import (
"golang.org/x/sys/windows" "golang.org/x/sys/windows"
) )
var microsoftDefenderLock = sync.Mutex{}
func AddMicrosoftDefenderExclusion() (err error) { func AddMicrosoftDefenderExclusion() (err error) {
microsoftDefenderLock.Lock()
defer microsoftDefenderLock.Unlock()
if !gulu.OS.IsWindows() { if !gulu.OS.IsWindows() {
return return
} }
@ -91,6 +97,9 @@ func AutoProcessMicrosoftDefender() {
} }
func checkMicrosoftDefender() { func checkMicrosoftDefender() {
microsoftDefenderLock.Lock()
defer microsoftDefenderLock.Unlock()
if !gulu.OS.IsWindows() || Conf.System.MicrosoftDefenderExcluded { if !gulu.OS.IsWindows() || Conf.System.MicrosoftDefenderExcluded {
return return
} }