解决添加和删除索引目录异常的问题
This commit is contained in:
parent
918fd9846c
commit
365f70642f
|
@ -139,15 +139,17 @@ void FileSystemWatcherPrivate::addWatchWithBlackList(const QStringList &pathList
|
||||||
QStringList FileSystemWatcherPrivate::removeWatch(const QString &path)
|
QStringList FileSystemWatcherPrivate::removeWatch(const QString &path)
|
||||||
{
|
{
|
||||||
QStringList paths;
|
QStringList paths;
|
||||||
for(int wd : m_watchPathHash.keys()) {
|
QHash<int, QString>::iterator iter = m_watchPathHash.begin();
|
||||||
QString tmpPath = m_watchPathHash.value(wd);
|
while(iter != m_watchPathHash.end()) {
|
||||||
if(tmpPath.length() >= path.length()) {
|
if(iter.value().length() >= path.length() && FileUtils::isOrUnder(iter.value(), path)) {
|
||||||
if(FileUtils::isOrUnder(tmpPath, path)) {
|
paths.append(iter.value());
|
||||||
//fix me:This function can be slow (O(n))
|
inotify_rm_watch(m_inotifyFd, iter.key());
|
||||||
paths.append(removeWatch(m_watchPathHash.key(path)));
|
iter = m_watchPathHash.erase(iter);
|
||||||
}
|
} else {
|
||||||
|
++iter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
m_watchPathHash.squeeze();
|
||||||
return paths;
|
return paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,7 @@ void IndexScheduler::addNewPath(const QString &folders, const QStringList &black
|
||||||
FirstRunIndexer *indexer = new FirstRunIndexer(QStringList(folders), blackList, m_stop, FirstRunIndexer::WorkMode::Add, target);
|
FirstRunIndexer *indexer = new FirstRunIndexer(QStringList(folders), blackList, m_stop, FirstRunIndexer::WorkMode::Add, target);
|
||||||
connect(indexer, &FirstRunIndexer::done, this, &IndexScheduler::addNewPathFinished, Qt::QueuedConnection);
|
connect(indexer, &FirstRunIndexer::done, this, &IndexScheduler::addNewPathFinished, Qt::QueuedConnection);
|
||||||
m_threadPool.start(indexer);
|
m_threadPool.start(indexer);
|
||||||
|
m_fileWatcher.addWatch(folders, blackList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue