Skip to content

Commit

Permalink
Fix aziz#147 (ignore DirModifiedEvent)
Browse files Browse the repository at this point in the history
this event seems useful only for monitoring the time changes, mostly
time of access, which is pointless in the particular case, and ignoring
it should significantly reduce excessive refresh calls
  • Loading branch information
vovkkk committed May 11, 2018
1 parent 9b1cda7 commit 0e9a671
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion 0_dired_fs_observer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
try: # unavailable dependencies shall not break basic functionality
import package_events
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
from watchdog.events import FileSystemEventHandler, DirModifiedEvent
except ImportError:
Observer = None
FileSystemEventHandler = object
Expand Down Expand Up @@ -167,6 +167,19 @@ def on_any_event(self, event):
not to be confused with package_events which we use for internal communication
dir(event) = ['event_type', 'is_directory', 'key', 'src_path']
'''
if isinstance(event, DirModifiedEvent):
# change of access time may cause modified event, which can be safely ignored
# actual changes will fire the corresponding event types:
# FileMovedEvent
# DirMovedEvent
# FileModifiedEvent
# FileCreatedEvent
# DirCreatedEvent
# FileDeletedEvent
# DirDeletedEvent
print('Ignore DirModified:', event.key)
return

src_path = event.src_path
path = os.path.dirname(src_path)
for v, p in self.paths.items():
Expand Down

0 comments on commit 0e9a671

Please sign in to comment.