Index: trunk/src/sh_fInotify.c
===================================================================
--- trunk/src/sh_fInotify.c	(revision 371)
+++ trunk/src/sh_fInotify.c	(revision 372)
@@ -111,5 +111,5 @@
 static int sh_fInotify_process(struct inotify_event * event);
 static int sh_fInotify_report(struct inotify_event * event, char * filename,
-			      int class, unsigned long check_mask);
+			      int class, unsigned long check_mask, int ftype);
 
 int sh_fInotify_init(struct mod_type * arg)
@@ -168,5 +168,6 @@
   ssize_t len = -1;
   char *  buffer = SH_ALLOC(16384);
-  static int count = 0;
+  static int count  = 0;
+  static int count2 = 0;
 
   if (ShfInotifyActive == S_FALSE)
@@ -211,10 +212,19 @@
   sh_inotify_recheck_watches (&sh_file_watches, &sh_file_missing);
 
-  ++count;
+  ++count; 
+  ++count2;
 
   if (count >= 10)
     {
-      count = 0; /* Re-expand glob patterns to discover added files */
+      count = 0; /* Re-expand glob patterns to discover added files. */
       sh_files_check_globFilePatterns();
+    }
+
+  if (count2 >= 300)
+    {
+      count2 = 0; /* Update baseline database. */
+      if (sh.flag.checkSum == SH_CHECK_CHECK && 
+	  sh.flag.update == S_TRUE)
+	sh_hash_writeout ();
     }
 
@@ -303,4 +313,5 @@
   char * filename;
   int    class;
+  int    type;
   unsigned long check_mask;
   int    retval;
@@ -323,8 +334,8 @@
 
   while (NULL != (filename = sh_inotify_pop_dormant(&sh_file_watches, 
-						    &class, &check_mask)))
+						    &class, &check_mask, &type)))
     {
       retval = sh_inotify_add_watch(filename, &sh_file_watches, &errnum,
-				    class, check_mask);
+				    class, check_mask, type);
 
       if (retval < 0)
@@ -367,4 +378,5 @@
 {
   int class;
+  int ftype;
   unsigned long check_mask;
   char * filename;
@@ -374,5 +386,7 @@
     {
       char dbgbuf[256];
+
       sl_strlcpy (dbgbuf, "inotify mask: ", sizeof(dbgbuf));
+
       if (event->mask & IN_ACCESS) sl_strlcat(dbgbuf, "IN_ACCESS ", sizeof(dbgbuf));
       if (event->mask & IN_ATTRIB) sl_strlcat(dbgbuf, "IN_ATTRIB ", sizeof(dbgbuf));
@@ -391,4 +405,5 @@
       if (event->mask & IN_Q_OVERFLOW) sl_strlcat(dbgbuf, "IN_Q_OVERFLOW ", sizeof(dbgbuf));
       if (event->mask & IN_UNMOUNT) sl_strlcat(dbgbuf, "IN_UNMOUNT ", sizeof(dbgbuf));
+
       SH_MUTEX_LOCK(mutex_thread_nolog);
       sh_error_handle(SH_ERR_ALL, FIL__, __LINE__, 0, MSG_E_SUBGEN, 
@@ -401,9 +416,9 @@
     {
       filename = sh_inotify_search_item(&sh_file_watches, event->wd, 
-					&class, &check_mask);
+					&class, &check_mask, &ftype);
 
       if (filename)
 	{
-	  sh_fInotify_report(event, filename, class, check_mask);
+	  sh_fInotify_report(event, filename, class, check_mask, ftype);
 
 	  SH_FREE(filename);
@@ -417,4 +432,5 @@
 	  /* Remove watch ? Seems reasonable. */
 	  sh_inotify_rm_watch(NULL, NULL, event->wd);
+
 	  SH_MUTEX_LOCK(mutex_thread_nolog);
 	  sh_error_handle((-1), FIL__, __LINE__, event->wd, MSG_E_SUBGEN, 
@@ -466,5 +482,5 @@
 
 static int sh_fInotify_report(struct inotify_event * event, char * filename,
-			      int class, unsigned long check_mask)
+			      int class, unsigned long check_mask, int ftype)
 {
   char * fullpath = NULL;
@@ -484,9 +500,16 @@
   if ( (event->mask & (IN_ATTRIB|IN_MODIFY)) != 0)
     {
-      sh_files_search_file(path, &class, &check_mask, &reported);
-
-      sh_files_filecheck (class, check_mask, filename,
-			  (event->len > 0) ? event->name : NULL,
-			  &reported, 0);
+      int ret = sh_files_search_file(path, &class, &check_mask, &reported);
+
+      if ((ret == 0) && (event->len > 0) && (ftype == SH_INOTIFY_FILE))
+	{
+	  ; /* do nothing */
+	}
+      else
+	{
+	  sh_files_filecheck (class, check_mask, filename,
+			      (event->len > 0) ? event->name : NULL,
+			      &reported, 0);
+	}
     }
   else if ((event->mask & (IN_DELETE|IN_DELETE_SELF|IN_MOVE_SELF|IN_MOVED_FROM)) != 0)
@@ -501,5 +524,14 @@
 	  if (0 != hashreport_missing(path, level))
 	    {
-	      sh_fInotify_report_miss(path, level);
+	      int ret = sh_files_search_file(path, &class, &check_mask, &reported);
+
+	      if ((ret == 0) && (event->len > 0) && (ftype == SH_INOTIFY_FILE))
+		{
+		  ; /* do nothing */
+		}
+	      else
+		{
+		  sh_fInotify_report_miss(path, level);
+		}
 	    }
 	}
@@ -513,7 +545,8 @@
 	sh_files_set_file_reported(path);
 
-      /* Move to 'dormant' list. 
+      /* Move to 'dormant' list, if not file within directory. 
        */
-      sh_inotify_rm_watch(&sh_file_watches, &sh_file_missing, event->wd);
+      if (event->len == 0)
+	sh_inotify_rm_watch(&sh_file_watches, &sh_file_missing, event->wd);
     }
   else if((event->mask & (IN_CREATE|IN_MOVED_TO)) != 0)
@@ -527,7 +560,15 @@
 	  ret = sh_files_search_file(path, &class, &check_mask, &reported);
 	  
-	  sh_files_filecheck (class, check_mask, filename,
-			      (event->len > 0) ? event->name : NULL,
-			      &reported, 0);
+	  if ((ret == 0) && (event->len > 0) && (ftype == SH_INOTIFY_FILE))
+	    {
+	      ; /* do nothing */
+	    }
+	  else
+	    {
+	      sh_files_filecheck (class, check_mask, filename,
+				  (event->len > 0) ? event->name : NULL,
+				  &reported, 0);
+	    }
+
 	  if (SH_FFLAG_REPORTED_SET(reported))
 	    sh_files_set_file_reported(path);
@@ -536,5 +577,5 @@
 	    {
 	      sh_inotify_add_watch(path, &sh_file_watches, &ret,
-				   class, check_mask);
+				   class, check_mask, SH_INOTIFY_FILE);
 	    }
 	}
Index: trunk/src/sh_files.c
===================================================================
--- trunk/src/sh_files.c	(revision 371)
+++ trunk/src/sh_files.c	(revision 372)
@@ -370,5 +370,5 @@
 	    {
 	      sh_inotify_add_watch_later(ptr->name, &sh_file_watches, NULL,
-					 ptr->class, ptr->check_mask);
+					 ptr->class, ptr->check_mask, SH_INOTIFY_FILE);
 	    }
 
@@ -1907,10 +1907,4 @@
     }
 
-  if ((sh.flag.inotify & SH_INOTIFY_DOSCAN) != 0)
-    {
-      sh_inotify_add_watch_later(iname, &sh_file_watches, &status,
-				 iclass, check_mask);
-    }
-   
   /* ---- stat the directory ----
    */
@@ -1955,4 +1949,10 @@
     }
 
+  if ((sh.flag.inotify & SH_INOTIFY_DOSCAN) != 0)
+    {
+      sh_inotify_add_watch_later(iname, &sh_file_watches, &status,
+				 iclass, check_mask, SH_INOTIFY_DIR);
+    }
+   
   hardlink_num = theFile->hardlinks;
 
Index: trunk/src/sh_inotify.c
===================================================================
--- trunk/src/sh_inotify.c	(revision 371)
+++ trunk/src/sh_inotify.c	(revision 372)
@@ -125,5 +125,6 @@
 {
   int    watch;
-  int    flag;
+  short  flag;
+  short  type;
   int    class;
   unsigned long check_mask;
@@ -355,5 +356,5 @@
 
 char * sh_inotify_pop_dormant(sh_watches * watches, 
-			      int * class, unsigned long * check_mask)
+			      int * class, unsigned long * check_mask, int * type)
 {
   char * popret = NULL;
@@ -372,4 +373,5 @@
     {
       *class = this->watch->class;
+      *type  = this->watch->type;
       *check_mask = this->watch->check_mask;
       popret = sh_util_strdup(this->watch->file);
@@ -472,5 +474,5 @@
 int sh_inotify_add_watch_later(char * filename, sh_watches * watches, 
 			       int * errnum,
-			       int class, unsigned long check_mask)
+			       int class, unsigned long check_mask, int type)
 {
   sh_watch   * item;
@@ -479,4 +481,5 @@
 
   item->class      = class;
+  item->type       = (short) type;
   item->check_mask = check_mask;
 
@@ -571,5 +574,5 @@
  */
 int sh_inotify_add_watch(char * filename, sh_watches * watches, int * errnum,
-			 int class, unsigned long check_mask)
+			 int class, unsigned long check_mask, int type)
 {
   volatile int retval = 0;
@@ -614,4 +617,5 @@
 
 	  item->class      = class;
+	  item->type       = type;
 	  item->check_mask = check_mask;
 	  
@@ -651,5 +655,5 @@
 
 char * sh_inotify_search_item(sh_watches * watches, int watch, 
-			      int * class, unsigned long * check_mask)
+			      int * class, unsigned long * check_mask, int * type)
 {
   sh_watch * item;
@@ -668,4 +672,5 @@
       *class      = item->class;
       *check_mask = item->check_mask;
+      *type       = item->type;
       sret = sh_util_strdup(item->file);
     }
@@ -705,5 +710,5 @@
       if (filename)
 	{
-	  if (sh_inotify_add_watch(filename, watches, errnum, 0, 0) < 0)
+	  if (sh_inotify_add_watch(filename, watches, errnum, 0, 0, SH_INOTIFY_FILE) < 0)
 	    {
 	      retry_msleep(waitsec, 0);
Index: trunk/src/sh_modules.c
===================================================================
--- trunk/src/sh_modules.c	(revision 371)
+++ trunk/src/sh_modules.c	(revision 372)
@@ -178,5 +178,5 @@
     N_("INOTIFY"),
     -1,
-    SH_MODFL_NOTIMER,
+    0,
     sh_fInotify_init,
     sh_fInotify_timer,
