Commits

Martín Lucas Golini committed 56e08b8

Inotify backend:
Fixed renamed watched folders internal path that wasn't being updated correctly.
Fixed recursive watches folders not being removed correctly.

Comments (0)

Files changed (3)

src/efsw/FileWatcherInotify.cpp

 		if ( watch->OldFileName.empty() )
 		{
 			watch->Listener->handleFileAction( watch->ID, watch->Directory, filename, Actions::Add );
+
+			checkForNewWatcher( watch, fpath );
 		}
 		else
 		{
 
 			for ( WatchMap::iterator it = mWatches.begin(); it != mWatches.end(); it++ )
 			{
-				if ( it->second->Directory == opath )
+				if ( it->second->Directory == opath && it->second->DirInfo.Inode == FileInfo( opath ).Inode )
 				{
-					it->second->Directory = fpath;
+					it->second->Directory	= fpath;
+					it->second->DirInfo		= FileInfo( fpath );
 
 					break;
 				}
 	{
 		watch->Listener->handleFileAction( watch->ID, watch->Directory, filename, Actions::Delete );
 
+		FileSystem::dirAddSlashAtEnd( fpath );
+
 		/// If the file erased is a directory and recursive is enabled, removes the directory erased
-		if ( watch->Recursive && FileSystem::isDirectory( fpath ) )
+		if ( watch->Recursive )
 		{
 			for ( WatchMap::iterator it = mWatches.begin(); it != mWatches.end(); it++ )
 			{

src/efsw/WatcherInotify.cpp

 
 WatcherInotify::WatcherInotify( WatchID id, std::string directory, FileWatchListener * listener, bool recursive, WatcherInotify * parent ) :
 	Watcher( id, directory, listener, recursive ),
-	Parent( parent )
+	Parent( parent ),
+	DirInfo( directory )
 {
 }
 

src/efsw/WatcherInotify.hpp

 #define EFSW_WATCHERINOTIFY_HPP
 
 #include <efsw/FileWatcherImpl.hpp>
+#include <efsw/FileInfo.hpp>
 
 namespace efsw {
 
 		
 		WatcherInotify( WatchID id, std::string directory, FileWatchListener * listener, bool recursive, WatcherInotify * parent = NULL );
 
+		bool inParentTree( WatcherInotify * parent );
+
 		WatcherInotify * Parent;
 
-		bool inParentTree( WatcherInotify * parent );
+		FileInfo DirInfo;
 };
 
 }