fix(ai-index):修复更新ai索引失败问题

This commit is contained in:
iaom 2024-04-26 09:02:11 +08:00
parent fe0950c576
commit 5c7a4ec1f9
2 changed files with 17 additions and 7 deletions

View File

@ -95,7 +95,13 @@ bool AiIndexer::addTextFileIndex(const QJsonArray &object)
if(!AiIndexerPrivate::m_sessionValid) { if(!AiIndexerPrivate::m_sessionValid) {
return false; return false;
} }
return data_management_add_text_files(AiIndexerPrivate::m_session, QJsonDocument(object).toJson().data()) == DataManagementResult::DATA_MANAGEMENT_SUCCESS; DataManagementResult result = data_management_add_text_files(AiIndexerPrivate::m_session, QJsonDocument(object).toJson().data());
if(result != DataManagementResult::DATA_MANAGEMENT_SUCCESS) {
qWarning() << "Fail to call data_management_add_text_files, input: " << QJsonDocument(object).toJson().data()
<< "result:" << result;
return false;
}
return true;
} }
bool AiIndexer::addImageFileIndex(const QJsonArray &object) bool AiIndexer::addImageFileIndex(const QJsonArray &object)
@ -103,7 +109,13 @@ bool AiIndexer::addImageFileIndex(const QJsonArray &object)
if(!AiIndexerPrivate::m_sessionValid) { if(!AiIndexerPrivate::m_sessionValid) {
return false; return false;
} }
return data_management_add_image_files(AiIndexerPrivate::m_session, QJsonDocument(object).toJson().data()) == DataManagementResult::DATA_MANAGEMENT_SUCCESS; DataManagementResult result = data_management_add_image_files(AiIndexerPrivate::m_session, QJsonDocument(object).toJson().data());
if(result != DataManagementResult::DATA_MANAGEMENT_SUCCESS) {
qWarning() << "Fail to call data_management_add_image_files, input: " << QJsonDocument(object).toJson().data()
<< "result:" << result;
return false;
}
return true;
} }
bool AiIndexer::deleteFileIndex(const QStringList &files) bool AiIndexer::deleteFileIndex(const QStringList &files)

View File

@ -230,13 +230,11 @@ void IndexUpdater::updateAiIndex()
return; return;
} }
qDebug() << "| index:" <<file.path(); qDebug() << "| index:" <<file.path();
if((indexer.*creat)(QJsonArray{ if(!(indexer.*creat)(QJsonArray{
QJsonObject{ QJsonObject{
{QStringLiteral("filepath"), file.path()}, {QStringLiteral("filepath"), file.path()},
{QStringLiteral("filetype"), type} {QStringLiteral("fileformat"), type}
}})) }})){
{
} else {
qWarning() << "Ai index failed for" << file.path(); qWarning() << "Ai index failed for" << file.path();
} }
}; };