Merge pull request #163 from iaom/0301-dev

[FIX]Index crash if database path don't exits.
This commit is contained in:
张佳萍 2021-03-08 11:57:31 +08:00 committed by GitHub
commit 94f4c74d48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 10 deletions

13
debian/changelog vendored
View File

@ -1,3 +1,16 @@
ukui-search (0.2.0+0306) v101; urgency=medium
* Feature: Add support for 'doc' file in file content search.
- 文本索引增加了对doc格式文件的支持。
* Fix: There is no web search result when there is no local result.
- 修复没有本地搜索结果时不显示网页搜索列表的问题。
* Fix:Files with special charactors can not be opened successfully.
- 修复带有特殊字符的文件无法正常打开的问题。
* Fix:Occasional crash during the first boot of system.
- 修复了在系统首次启动时偶现的崩溃问题。
-- zhangpengfei <zhangpengfei@kylinos.cn> Sat, 06 Mar 2021 11:03:20 +0800
ukui-search (0.2.0+0301) v101; urgency=medium ukui-search (0.2.0+0301) v101; urgency=medium
* Fix: New result won't be added to expanded list. * Fix: New result won't be added to expanded list.

View File

@ -28,8 +28,8 @@
#include <QQueue> #include <QQueue>
#include <QPair> #include <QPair>
#include <QMutex> #include <QMutex>
#define INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/index_data").toStdString() #define INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/ukui-search/index_data").toStdString()
#define CONTENT_INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/content_index_data").toStdString() #define CONTENT_INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/ukui-search/content_index_data").toStdString()
class FileSearcher : public QObject class FileSearcher : public QObject

View File

@ -33,8 +33,8 @@
#include <QStandardPaths> #include <QStandardPaths>
#define INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/index_data").toStdString() #define INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/ukui-search/index_data").toStdString()
#define CONTENT_INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/content_index_data").toStdString() #define CONTENT_INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/ukui-search/content_index_data").toStdString()
static IndexGenerator *global_instance = nullptr; static IndexGenerator *global_instance = nullptr;
QMutex IndexGenerator::m_mutex; QMutex IndexGenerator::m_mutex;
@ -144,15 +144,28 @@ bool IndexGenerator::creatAllIndex(QQueue<QString> *messageList)
IndexGenerator::IndexGenerator(bool rebuild, QObject *parent) : QObject(parent) IndexGenerator::IndexGenerator(bool rebuild, QObject *parent) : QObject(parent)
{ {
if(rebuild) QDir database(QString::fromStdString(INDEX_PATH));
if(database.exists())
{ {
QDir database(QString::fromStdString(INDEX_PATH)); if(rebuild)
if(database.exists())
qDebug()<<"remove"<<database.removeRecursively();
database.setPath(QString::fromStdString(CONTENT_INDEX_PATH));
if(database.exists())
qDebug()<<"remove"<<database.removeRecursively(); qDebug()<<"remove"<<database.removeRecursively();
} }
else
{
qDebug()<<"create index path"<<database.mkpath(QString::fromStdString(INDEX_PATH));
}
database.setPath(QString::fromStdString(CONTENT_INDEX_PATH));
if(database.exists())
{
if(rebuild)
qDebug()<<"remove"<<database.removeRecursively();
}
else
{
qDebug()<<"create content index path"<<database.mkpath(QString::fromStdString(CONTENT_INDEX_PATH));
}
m_database_path = new Xapian::WritableDatabase(INDEX_PATH, Xapian::DB_CREATE_OR_OPEN); m_database_path = new Xapian::WritableDatabase(INDEX_PATH, Xapian::DB_CREATE_OR_OPEN);
m_database_content = new Xapian::WritableDatabase(CONTENT_INDEX_PATH, Xapian::DB_CREATE_OR_OPEN); m_database_content = new Xapian::WritableDatabase(CONTENT_INDEX_PATH, Xapian::DB_CREATE_OR_OPEN);
} }