[Linux] Avoid recursive inotify when a watch folder is set to recursive=false
Signed-off-by: Chris Burel <burelc@amazon.com>
This commit is contained in:
@@ -49,7 +49,7 @@ FileWatcher::~FileWatcher()
|
||||
{
|
||||
}
|
||||
|
||||
int FileWatcher::AddFolderWatch(FolderWatchBase* pFolderWatch)
|
||||
int FileWatcher::AddFolderWatch(FolderWatchBase* pFolderWatch, bool recursive)
|
||||
{
|
||||
if (!pFolderWatch)
|
||||
{
|
||||
@@ -72,7 +72,7 @@ int FileWatcher::AddFolderWatch(FolderWatchBase* pFolderWatch)
|
||||
if (!pFolderRootWatch)
|
||||
{
|
||||
//create a new root and start listening for changes
|
||||
pFolderRootWatch = new FolderRootWatch(pFolderWatch->m_folder);
|
||||
pFolderRootWatch = new FolderRootWatch(pFolderWatch->m_folder, recursive);
|
||||
|
||||
//make sure the folder watcher(s) get deleted before this
|
||||
pFolderRootWatch->setParent(this);
|
||||
@@ -93,7 +93,7 @@ int FileWatcher::AddFolderWatch(FolderWatchBase* pFolderWatch)
|
||||
//of other roots, if it is then then fold those roots into the new super root
|
||||
for (auto rootsIter = m_folderWatchRoots.begin(); rootsIter != m_folderWatchRoots.end(); )
|
||||
{
|
||||
if (FolderWatchBase::IsSubfolder((*rootsIter)->m_root, pFolderWatch->m_folder))
|
||||
if (pFolderWatch->m_watchSubtree && FolderWatchBase::IsSubfolder((*rootsIter)->m_root, pFolderWatch->m_folder))
|
||||
{
|
||||
//union the sub folder map over to the new root
|
||||
pFolderRootWatch->m_subFolderWatchesMap.insert((*rootsIter)->m_subFolderWatchesMap);
|
||||
|
||||
@@ -33,7 +33,7 @@ class FolderRootWatch
|
||||
|
||||
friend class FileWatcher;
|
||||
public:
|
||||
FolderRootWatch(const QString rootFolder);
|
||||
FolderRootWatch(const QString rootFolder, bool recursive = true);
|
||||
virtual ~FolderRootWatch();
|
||||
|
||||
void ProcessNewFileEvent(const QString& file);
|
||||
@@ -54,6 +54,7 @@ private:
|
||||
QMap<int, FolderWatchBase*> m_subFolderWatchesMap;
|
||||
volatile bool m_shutdownThreadSignal;
|
||||
FileWatcher* m_fileWatcher;
|
||||
bool m_recursive;
|
||||
|
||||
// Can't use unique_ptr because this is a QObject and Qt's magic sauce is
|
||||
// unable to determine the size of the unique_ptr and so fails to compile
|
||||
@@ -76,7 +77,7 @@ public:
|
||||
virtual ~FileWatcher();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
virtual int AddFolderWatch(FolderWatchBase* pFolderWatch);
|
||||
virtual int AddFolderWatch(FolderWatchBase* pFolderWatch, bool recursive = true);
|
||||
virtual void RemoveFolderWatch(int handle);
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -461,7 +461,7 @@ void ApplicationManagerBase::InitFileMonitor()
|
||||
m_fileProcessor.get(), &AssetProcessor::FileProcessor::AssessDeletedFile);
|
||||
|
||||
m_folderWatches.push_back(AZStd::unique_ptr<FolderWatchCallbackEx>(newFolderWatch));
|
||||
m_watchHandles.push_back(m_fileWatcher.AddFolderWatch(newFolderWatch));
|
||||
m_watchHandles.push_back(m_fileWatcher.AddFolderWatch(newFolderWatch, info.RecurseSubFolders()));
|
||||
}
|
||||
|
||||
// also hookup monitoring for the cache (output directory)
|
||||
|
||||
Reference in New Issue
Block a user