Skip to content

Commit

Permalink
Snapshot: don't walk directories without read permissions
Browse files Browse the repository at this point in the history
Original patch by Joshua Skelton (@joshuaskelly) on issue gorakhargosh#408.
  • Loading branch information
BoboTiG committed Jun 13, 2019
1 parent a8db635 commit 191108d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/watchdog/utils/dirsnapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,16 @@ def walk(root):
yield _
if recursive:
for path, st in entries:
if S_ISDIR(st.st_mode):
for _ in walk(path):
yield _
try:
if S_ISDIR(st.st_mode):
for _ in walk(path):
yield _
except (IOError, OSError) as e:
# IOError for Python 2
# OSError for Python 3
# (should be only PermissionError when dropping Python 2 support)
if e.errno != errno.EACCES:
raise

for p, st in walk(path):
i = (st.st_ino, st.st_dev)
Expand Down

0 comments on commit 191108d

Please sign in to comment.