diff options
author | Sol Jerome <sol.jerome@gmail.com> | 2011-08-02 09:12:41 -0500 |
---|---|---|
committer | Sol Jerome <sol.jerome@gmail.com> | 2011-08-02 09:12:41 -0500 |
commit | 7169c6cb1f10dd0ff98d16176cd55329079e7c25 (patch) | |
tree | e8015f69207bfcec1fe3b65e285dce145e736e28 /src/lib/Server | |
parent | 6a537a6451233f42ffff70953972c1c04c5eeb29 (diff) | |
parent | 7fd2e4c470041c353c2632fd0a838c43cb3c4a99 (diff) | |
download | bcfg2-7169c6cb1f10dd0ff98d16176cd55329079e7c25.tar.gz bcfg2-7169c6cb1f10dd0ff98d16176cd55329079e7c25.tar.bz2 bcfg2-7169c6cb1f10dd0ff98d16176cd55329079e7c25.zip |
Merge branch 'master' of https://github.com/mikemccllstr/bcfg2
Diffstat (limited to 'src/lib/Server')
-rw-r--r-- | src/lib/Server/Plugin.py | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/lib/Server/Plugin.py b/src/lib/Server/Plugin.py index 0f45f53f1..f14788bce 100644 --- a/src/lib/Server/Plugin.py +++ b/src/lib/Server/Plugin.py @@ -387,7 +387,7 @@ class DirectoryBacked(object): """ object.__init__(self) - self.data = data + self.data = os.path.normpath(data) self.fam = fam # self.entries contains information about the files monitored @@ -441,17 +441,18 @@ class DirectoryBacked(object): """ action = event.code2str() - # Exclude events for actions and filesystem paths we don't - # care about + # Clean up the absolute path names passed in + event.filename = os.path.normpath(event.filename) + if event.filename.startswith(self.data): + event.filename = event.filename[len(self.data)+1:] + + # Exclude events for actions we don't care about if action == 'endExist': return - elif os.path.isabs(event.filename[0]): - # After AddDirectoryMonitor calls, we receive an 'exists' - # event with the just-added directory and its absolute - # path name. Ignore these. - return - elif event.filename == '': - logger.warning("Got event for blank filename") + + if event.requestID not in self.handles: + logger.warn("Got %s event with unknown handle (%s) for %s" + % (action, event.requestID, abspath)) return # Calculate the absolute and relative paths this event refers to @@ -463,9 +464,11 @@ class DirectoryBacked(object): for key in self.entries.keys(): if key.startswith(relpath): del self.entries[key] - for handle in self.handles.keys(): - if self.handles[handle].startswith(relpath): - del self.handles[handle] + # We remove values from self.entries, but not + # self.handles, because the FileMonitor doesn't stop + # watching a directory just because it gets deleted. If it + # is recreated, we will start getting notifications for it + # again without having to add a new monitor. elif posixpath.isdir(abspath): # Deal with events for directories if action in ['exists', 'created']: |