Merge branch 'main' of https://git.ciy.cn/wk233/sysmonitord
This commit is contained in:
commit
50e7086192
|
|
@ -39,4 +39,7 @@ config.local.yaml
|
||||||
todo.txt
|
todo.txt
|
||||||
|
|
||||||
# 测试文件
|
# 测试文件
|
||||||
test/
|
test/
|
||||||
|
|
||||||
|
# 编译文件
|
||||||
|
sysmonitord
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,10 @@ func (m *Manager) IsPathIgnored(path string) bool {
|
||||||
m.mu.RLock()
|
m.mu.RLock()
|
||||||
defer m.mu.RUnlock()
|
defer m.mu.RUnlock()
|
||||||
|
|
||||||
|
return m.IsPathIgnoredUnsafe(path)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Manager) IsPathIgnoredUnsafe(path string) bool {
|
||||||
path = filepath.Clean(path)
|
path = filepath.Clean(path)
|
||||||
for _, ignore := range m.mergedIgnore {
|
for _, ignore := range m.mergedIgnore {
|
||||||
if strings.HasPrefix(path, filepath.Clean(ignore)) {
|
if strings.HasPrefix(path, filepath.Clean(ignore)) {
|
||||||
|
|
@ -59,10 +63,11 @@ func (m *Manager) IsPathIgnored(path string) bool {
|
||||||
// CheckFileStatus 检查文件状态
|
// CheckFileStatus 检查文件状态
|
||||||
// 返回: isWhitelisted(是否在白名单), isValid(Hash是否匹配), err
|
// 返回: isWhitelisted(是否在白名单), isValid(Hash是否匹配), err
|
||||||
func (m *Manager) CheckFileStatus(path string) (bool, bool, error) {
|
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
|
return true, true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user