Skip to content

Commit

Permalink
update dirshapshot to use new stat function
Browse files Browse the repository at this point in the history
  • Loading branch information
tamland committed Feb 15, 2014
1 parent 54c2730 commit f8b6640
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/watchdog/utils/dirsnapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,13 @@ class DirectorySnapshot(object):
"""

def __init__(self, path, recursive=True, walker_callback=(lambda p, s: None)):
statf = os.stat
from watchdog.utils import stat
statf = stat
walker = path_walk
self._has_inodes = not platform.is_windows()
self._stat_info = {}
self._inode_to_path = {}

stat_info = os.stat(path)
stat_info = statf(path)
self._stat_info[path] = stat_info
self._inode_to_path[stat_info.st_ino] = self.path

Expand Down Expand Up @@ -245,16 +245,12 @@ def path(self, inode):
"""
Returns path for inode. None if inode is unknown to this snapshot.
"""
if not self._has_inodes:
return None
return self._inode_to_path.get(inode)

def inode(self, path):
"""
Returns inode for path. 0 if inode is unknown.
Returns inode for path.
"""
if not self._has_inodes:
return 0
return self._stat_info[path].st_ino

def isdir(self, path):
Expand Down

0 comments on commit f8b6640

Please sign in to comment.