Skip to content

fix: Update index readiness check to allow for multiple valid statuses#182

Merged
deepin-bot[bot] merged 2 commits intolinuxdeepin:masterfrom
Johnson-zs:master
Jun 27, 2025
Merged

fix: Update index readiness check to allow for multiple valid statuses#182
deepin-bot[bot] merged 2 commits intolinuxdeepin:masterfrom
Johnson-zs:master

Conversation

@Johnson-zs
Copy link
Contributor

This commit modifies the isFileNameIndexReadyForSearch function to check if the index status is either "scanning" or "monitoring" instead of just "monitoring". This change improves the flexibility of the index readiness validation, ensuring that the search can proceed under more conditions while providing clearer debug output regarding the expected status.

Log:

This commit modifies the `isFileNameIndexReadyForSearch` function to check if the index status is either "scanning" or "monitoring" instead of just "monitoring". This change improves the flexibility of the index readiness validation, ensuring that the search can proceed under more conditions while providing clearer debug output regarding the expected status.

Log:
@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Johnson-zs

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@deepin-ci-robot
Copy link

deepin pr auto review

代码审查意见:

  1. 代码注释:在searchutility.cpp文件中,新增的validStatus列表应该添加注释说明其用途,以便其他开发者理解。

  2. 错误信息:在qDebug()输出中,错误信息应该更加详细,指出哪些状态是有效的,而不是仅仅指出期望的状态。例如,可以输出validStatus列表。

  3. 代码可读性:在if条件判断中,使用!validStatus.contains(status)替代status != "monitoring"可以提高代码的可读性,因为validStatus列表包含了所有有效的状态。

  4. 代码维护:如果validStatus列表中的状态会发生变化,建议将其定义为一个常量,并放在一个单独的头文件中,以便于维护和修改。

  5. 日志级别qDebug()用于调试信息,如果这是生产环境中的代码,建议使用更合适的日志级别,如qWarning()qCritical(),以便于区分不同级别的日志信息。

  6. 代码风格:在qDebug()输出中,建议使用<<操作符来格式化输出,而不是直接拼接字符串,以提高代码的可读性和维护性。

综合以上意见,修改后的代码可能如下:

// utils/searchutility.cpp

#include "searchutility.h"

// 常量定义,包含所有有效的状态
const QStringList validStatus = { "scanning", "monitoring" };

bool isFileNameIndexReadyForSearch()
{
    // 其他代码...

    const QString &status = currentStatus.value();
    if (!validStatus.contains(status)) {
        // 输出所有有效的状态,以便于调试和维护
        qDebug() << "Index status is '" << status
                 << "', expected one of: " << validStatus.join(", ")
                 << ". Index not ready for search.";
        return false;
    }

    // 其他代码...
}

以上修改提高了代码的可读性、可维护性和可扩展性。

@github-actions
Copy link

TAG Bot

TAG: 1.3.31
EXISTED: no
DISTRIBUTION: unstable

@Johnson-zs
Copy link
Contributor Author

/forcemerge

@deepin-bot
Copy link

deepin-bot bot commented Jun 27, 2025

This pr force merged! (status: blocked)

@deepin-bot deepin-bot bot merged commit 9f52461 into linuxdeepin:master Jun 27, 2025
21 checks passed
@lzwind
Copy link
Contributor

lzwind commented Jun 27, 2025

/topic cd-20250627

@deepin-ci-robot
Copy link

Add topic: cd-20250627 successed.

@lzwind
Copy link
Contributor

lzwind commented Jun 27, 2025

/integr-topic cd-20250627

@deepin-ci-robot
Copy link

Integrated with pr deepin-community/Repository-Integration#2959

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants