This commit is contained in:
wuko233 2026-02-17 11:27:56 +08:00
commit 50e7086192
2 changed files with 12 additions and 4 deletions

3
.gitignore vendored
View File

@ -40,3 +40,6 @@ todo.txt
# 测试文件
test/
# 编译文件
sysmonitord

View File

@ -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
}