Fix: there's something wrong when the index path which will be added is not exists or is already be added.
This commit is contained in:
parent
6e7ca5e35c
commit
fc4fc82cab
|
@ -73,13 +73,18 @@ QStringList DirWatcher::currentBlackListOfIndex()
|
||||||
return blackListOfIndex;
|
return blackListOfIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DirWatcher::handleIndexItemAppend(const QString &path)
|
void DirWatcher::handleIndexItemAppend(const QString &path, QStringList &blackList)
|
||||||
{
|
{
|
||||||
|
if (m_indexableDirList.contains(path)) {
|
||||||
|
qDebug() << QString("index path %1 is already added.").arg(path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
m_indexableDirList << path;
|
m_indexableDirList << path;
|
||||||
m_indexableDirList.removeDuplicates();
|
|
||||||
m_qSettings->beginGroup(INDEXABLE_DIR_VALUE);
|
m_qSettings->beginGroup(INDEXABLE_DIR_VALUE);
|
||||||
m_qSettings->setValue(INDEXABLE_DIR_VALUE, m_indexableDirList);
|
m_qSettings->setValue(INDEXABLE_DIR_VALUE, m_indexableDirList);
|
||||||
m_qSettings->endGroup();
|
m_qSettings->endGroup();
|
||||||
|
Q_EMIT this->appendIndexItem(path, blackList);
|
||||||
|
qDebug() << "index path:" << path << "blacklist:" << blackList;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DirWatcher::handleIndexItemRemove(const QString &path)
|
void DirWatcher::handleIndexItemRemove(const QString &path)
|
||||||
|
@ -226,11 +231,14 @@ void DirWatcher::mountRemoveCallback(GVolumeMonitor *monitor, GMount *gmount, Di
|
||||||
|
|
||||||
void DirWatcher::appendIndexableListItem(const QString &path)
|
void DirWatcher::appendIndexableListItem(const QString &path)
|
||||||
{
|
{
|
||||||
|
QFile file(path);
|
||||||
|
if (!file.exists()) {
|
||||||
|
qWarning() << QString("target path:%1 is not exists!").arg(path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (path == "/") {
|
if (path == "/") {
|
||||||
this->currentindexableDir();
|
this->currentindexableDir();
|
||||||
this->handleIndexItemAppend(path);
|
this->handleIndexItemAppend(path, m_blackListOfIndex);
|
||||||
Q_EMIT this->appendIndexItem(path, m_blackListOfIndex);
|
|
||||||
qDebug() << "index path:" << path << "blacklist:" << m_blackListOfIndex;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,9 +271,7 @@ void DirWatcher::appendIndexableListItem(const QString &path)
|
||||||
blackList.append(indexablePath);
|
blackList.append(indexablePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this->handleIndexItemAppend(path);
|
this->handleIndexItemAppend(path, blackList);
|
||||||
Q_EMIT this->appendIndexItem(path, blackList);
|
|
||||||
qDebug() << "index path:" << path << "blacklist:" << blackList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DirWatcher::removeIndexableListItem(const QString &path)
|
void DirWatcher::removeIndexableListItem(const QString &path)
|
||||||
|
|
|
@ -30,8 +30,6 @@ public:
|
||||||
void initDbusService();
|
void initDbusService();
|
||||||
QStringList currentindexableDir();
|
QStringList currentindexableDir();
|
||||||
QStringList currentBlackListOfIndex();
|
QStringList currentBlackListOfIndex();
|
||||||
void handleIndexItemAppend(const QString &path);
|
|
||||||
void handleIndexItemRemove(const QString &path);
|
|
||||||
void appendBlackListItemOfIndex(const QString &path);
|
void appendBlackListItemOfIndex(const QString &path);
|
||||||
void appendBlackListItemOfIndex(const QStringList &pathList);
|
void appendBlackListItemOfIndex(const QStringList &pathList);
|
||||||
void removeBlackListItemOfIndex(const QString &path);
|
void removeBlackListItemOfIndex(const QString &path);
|
||||||
|
@ -56,6 +54,9 @@ private:
|
||||||
void initData();
|
void initData();
|
||||||
void initDiskWatcher();
|
void initDiskWatcher();
|
||||||
|
|
||||||
|
void handleIndexItemAppend(const QString &path, QStringList &blackList);
|
||||||
|
void handleIndexItemRemove(const QString &path);
|
||||||
|
|
||||||
static QMutex s_mutex;
|
static QMutex s_mutex;
|
||||||
|
|
||||||
GVolumeMonitor *m_volumeMonitor = nullptr;
|
GVolumeMonitor *m_volumeMonitor = nullptr;
|
||||||
|
|
Loading…
Reference in New Issue