From 669a5b36724ea6e3a7a9e8481749023b9f53c7f1 Mon Sep 17 00:00:00 2001 From: wk233 Date: Tue, 17 Feb 2026 11:19:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E6=97=B6=E6=AD=BB=E9=94=81=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=9B=E4=BF=AE=E6=94=B9.gitignore=E6=96=87=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0=E7=BC=96=E8=AF=91=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 5 ++++- internal/whitelist/manager.go | 11 ++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index dc5e335..f17875d 100644 --- a/.gitignore +++ b/.gitignore @@ -39,4 +39,7 @@ config.local.yaml todo.txt # 测试文件 -test/ \ No newline at end of file +test/ + +# 编译文件 +sysmonitord diff --git a/internal/whitelist/manager.go b/internal/whitelist/manager.go index de25ae9..a205f2b 100644 --- a/internal/whitelist/manager.go +++ b/internal/whitelist/manager.go @@ -47,6 +47,10 @@ func (m *Manager) IsPathIgnored(path string) bool { m.mu.RLock() defer m.mu.RUnlock() + return m.IsPathIgnoredUnsafe(path) +} + +func (m *Manager) IsPathIgnoredUnsafe(path string) bool { path = filepath.Clean(path) for _, ignore := range m.mergedIgnore { if strings.HasPrefix(path, filepath.Clean(ignore)) { @@ -59,10 +63,11 @@ func (m *Manager) IsPathIgnored(path string) bool { // CheckFileStatus 检查文件状态 // 返回: isWhitelisted(是否在白名单), isValid(Hash是否匹配), err func (m *Manager) CheckFileStatus(path string) (bool, bool, error) { - m.mu.Lock() - defer m.mu.Unlock() - if m.IsPathIgnored((path)) { + m.mu.RLock() + defer m.mu.RUnlock() + + if m.IsPathIgnoredUnsafe((path)) { return true, true, nil }