From 7a428f64f6c04e777030fead124fc4c48b4ac728 Mon Sep 17 00:00:00 2001
From: "Arthur T. Glowacki" <aglowacki@aps.anl.gov>
Date: Fri, 2 Oct 2015 21:18:44 +0000
Subject: [PATCH] bug fix: Daq would not see files if you don't set have a / at
 the end of the data-directory

---
 .../service/impl/dmFileSystemEventHandler.py        | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/python/dm/daq_web_service/service/impl/dmFileSystemEventHandler.py b/src/python/dm/daq_web_service/service/impl/dmFileSystemEventHandler.py
index a5ece2de..b7ba939b 100755
--- a/src/python/dm/daq_web_service/service/impl/dmFileSystemEventHandler.py
+++ b/src/python/dm/daq_web_service/service/impl/dmFileSystemEventHandler.py
@@ -2,7 +2,6 @@
 
 import os
 import glob
-
 from watchdog.events import FileSystemEventHandler
 
 from dm.common.utility.loggingManager import LoggingManager
@@ -37,13 +36,17 @@ class DmFileSystemEventHandler(FileSystemEventHandler):
 
     def on_modified(self, event):
         FileSystemEventHandler.on_modified(self, event)
+        self.logger.debug('File system directory modified event: %s' % (event.__dict__))
         if event.is_directory:
             try:
-                filePath = max(glob.glob(event.src_path+'*.*'), key=os.path.getctime)
-                self.logger.debug('File system directory modified event: %s , latest file: %s' % (event.__dict__, filePath))
-                self.fileSystemObserver.fileUpdated(filePath, self.dataDirectory, self.experiment)
+                files = glob.glob(event.src_path+'/*.*')
+                self.logger.debug('File system directory modified event: %s , src path: %s ,  latest files: %s' % (event.__dict__, event.src_path, files))
+                if len(files) > 0:
+                    filePath = max(files, key=os.path.getctime)
+                    self.logger.debug('File system directory modified event: %s , latest file: %s' % (event.__dict__, filePath))
+                    self.fileSystemObserver.fileUpdated(filePath, self.dataDirectory, self.experiment)
             except:
-                self.logger.debug('Exception occured when searching for file in directory: %s' % (event.__dict__))
+                self.logger.error('Exception occured when searching for file in directory: %s' % (event.__dict__))
         else:
 	    filePath = event.src_path
             self.logger.debug('File system modified event: %s' % (event.__dict__))
-- 
GitLab