updated regex used in wildcard matching in file monitor to work on windows because why would things work on all systems

This commit is contained in:
PatchOfScotland
2023-03-15 15:16:38 +01:00
parent 23e9243b69
commit a7f910ecff

View File

@ -194,8 +194,12 @@ class WatchdogMonitor(BaseMonitor):
# Use regex to match event paths against rule paths
target_path = rule.pattern.triggering_path
recursive_regexp = translate(target_path)
direct_regexp = recursive_regexp.replace(
'.*', '[^'+ os.path.sep +']*')
if os.name == 'nt':
direct_regexp = recursive_regexp.replace(
'.*', '[^'+ os.path.sep + os.path.sep +']*')
else:
direct_regexp = recursive_regexp.replace(
'.*', '[^'+ os.path.sep +']*')
recursive_hit = match(recursive_regexp, handle_path)
direct_hit = match(direct_regexp, handle_path)