🎨 Improve ms defender check

This commit is contained in:
Daniel 2024-12-31 17:57:56 +08:00
parent 3807f8386c
commit 4e7b0d1125
No known key found for this signature in database
GPG Key ID: 86211BA83DF03017
2 changed files with 8 additions and 11 deletions

View File

@ -43,7 +43,7 @@ func StartCron() {
go every(30*time.Second, model.FlushAssetsTextsJob) go every(30*time.Second, model.FlushAssetsTextsJob)
go every(30*time.Second, model.HookDesktopUIProcJob) go every(30*time.Second, model.HookDesktopUIProcJob)
go every(24*time.Hour, model.AutoPurgeRepoJob) go every(24*time.Hour, model.AutoPurgeRepoJob)
go every(30*time.Minute, model.AutoProcessMicrosoftDefender) go every(30*time.Minute, model.AutoCheckMicrosoftDefender)
} }
func every(interval time.Duration, f func()) { func every(interval time.Duration, f func()) {

View File

@ -21,6 +21,10 @@ package model
import ( import (
"errors" "errors"
"fmt" "fmt"
"github.com/88250/gulu"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/util"
"golang.org/x/sys/windows"
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
@ -28,11 +32,7 @@ import (
"strings" "strings"
"sync" "sync"
"syscall" "syscall"
"time"
"github.com/88250/gulu"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/util"
"golang.org/x/sys/windows"
) )
var microsoftDefenderLock = sync.Mutex{} var microsoftDefenderLock = sync.Mutex{}
@ -98,11 +98,8 @@ func AddMicrosoftDefenderExclusion() (err error) {
return return
} }
func AutoProcessMicrosoftDefender() { func AutoCheckMicrosoftDefender() {
checkMicrosoftDefender() time.Sleep(7 * time.Second)
}
func checkMicrosoftDefender() {
microsoftDefenderLock.Lock() microsoftDefenderLock.Lock()
defer microsoftDefenderLock.Unlock() defer microsoftDefenderLock.Unlock()