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

This commit is contained in:
iaom 2024-04-26 09:02:11 +08:00
parent f4e5090beb
commit 4d20ad9b94
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) {
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)
@ -103,7 +109,13 @@ bool AiIndexer::addImageFileIndex(const QJsonArray &object)
if(!AiIndexerPrivate::m_sessionValid) {
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)

View File

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