Skip to content

Commit

Permalink
Add support for fileEvents to built-in poll, to ignore directories and
Browse files Browse the repository at this point in the history
symlinks, part of work for: #795, #791, and MetPX/sr_insects#26
  • Loading branch information
petersilva committed Nov 2, 2023
1 parent 7d2e90f commit 6a003cc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion sarracenia/flowcb/poll/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,9 +513,15 @@ def poll_file_post(self, desc, destDir, remote_file):
msg = sarracenia.Message.fromFileInfo(post_relPath, self.o, desc)

if stat.S_ISDIR(desc.st_mode):
msg['fileOp'] = { 'directory':'' }
if 'mkdir' not in self.o.fileEvents:
return None

msg['fileOp'] = { 'directory':'' }

elif stat.S_ISLNK(desc.st_mode):
if 'link' not in self.o.fileEvents:
return None

if not self.o.follow_symlinks:
try:
msg['fileOp'] = { 'link': self.dest.readlink(path) }
Expand All @@ -524,6 +530,9 @@ def poll_file_post(self, desc, destDir, remote_file):
logger.debug('Exception details: ', exc_info=True)
return None

if 'create' not in self.o.fileEvents and 'modify' not in self.o.fileEvents:
return None

if self.o.identity_method and (',' in self.o.identity_method):
m, v = self.o.identity_method.split(',')
msg['identity'] = {'method': m, 'value': v}
Expand Down

0 comments on commit 6a003cc

Please sign in to comment.