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 }