🎨 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.HookDesktopUIProcJob)
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()) {

View File

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