Index: trunk/src/sh_fInotify.c
===================================================================
--- trunk/src/sh_fInotify.c	(revision 505)
+++ trunk/src/sh_fInotify.c	(revision 506)
@@ -633,7 +633,8 @@
 	      retD = sh_files_search_dir(path, &classD, &check_flagsD, 
 					 &reportedD, &rdepthD);
+
 	      if (retD != 0)
 		{
-		  if (ret == 0)
+		  if (ret == 0) /* because checked as file below */
 		    {
 		      class      = classD;
@@ -641,4 +642,5 @@
 		    }
 		}
+	      rdepthD -= 1; if (rdepthD < -1) rdepthD = -1;
 	    }
 	  
@@ -650,4 +652,5 @@
 	    {
 	      SH_INOTIFY_IFUSED( sh.flag.inotify |= SH_INOTIFY_INSCAN;   );
+	      /* Here we use classD because we check as directory now */
 	      sh_files_checkdir (classD, check_flagsD, rdepthD, 
 				 path, (event->len > 0) ? event->name : NULL);
@@ -657,5 +660,4 @@
 	      sh_files_reset ();
 	    }
-	  
 	}
       
@@ -665,7 +667,12 @@
       if ((ret != 0) || (event->mask & IN_ISDIR))
 	{
+	  int inotify_type = SH_INOTIFY_FILE;
+	  
+	  if ((event->mask & IN_ISDIR) && (rdepthD >= 0))
+	    inotify_type = SH_INOTIFY_DIR;
+
 	  sh_inotify_add_watch(path, &sh_file_watches, &ret,
 			       class, check_flags, 
-			       (event->mask & IN_ISDIR)?SH_INOTIFY_DIR:SH_INOTIFY_FILE, 
+			       inotify_type, 
 			       rdepthD);
 	}
