feat: refine filename index data source validation - #266
Johnson-zs merged 1 commit into
Conversation
1. Enhanced the filename index validation for watch seeding and file enumeration operations 2. Changed FSMonitorWorker's fast directory scan from using isFileNameIndexReadyForSearch() to new isFileNameIndexUsableAsDataSource() method 3. Added disabled flag to persistent index state to track user's enable/ disable intent 4. Updated index status store to handle disabled flag with proper persistence 5. Modified FileNameIndexDBus::SetEnabled() to persistently record user's enable/disable decision 6. Added comprehensive unit tests for new validation logic The changes address a critical issue where the filename index validation was too strict for internal data source usage. Previously, the FSMonitorWorker used dfm-search's ready-for-search check which blocked fast directory scanning during normal index maintenance operations. The new validation distinguishes between search readiness (for external consumers) and data source usability (for internal operations), allowing index operations to continue during recovery/rebuild updates and backlog conditions while still blocking when the index is truly unusable. Log: Refined filename index validation for better performance during maintenance operations Influence: 1. Test fast directory scan behavior when index is in various states (creating, updating, disabled, backlog exceeded) 2. Verify user enable/disable functionality properly sets and persists disabled flag 3. Test that directories created during update operations still get monitored correctly 4. Verify that index continues to function during updateInProgress and backlogExceeded states 5. Test index usability with corrupted or missing status.json files feat: 优化文件名索引数据源验证逻辑 1. 增强文件名索引验证机制,专门用于监视种子播撒和文件枚举操作 2. 将FSMonitorWorker的快速目录扫描从使用isFileNameIndexReadyForSearch() 改为新的isFileNameIndexUsableAsDataSource()方法 3. 向持久化索引状态添加禁用标志,以跟踪用户的启用/禁用意图 4. 更新索引状态存储以正确处理禁用标志的持久化 5. 修改FileNameIndexDBus::SetEnabled()来持久记录用户的启用/禁用决定 6. 为新的验证逻辑添加全面的单元测试 这些变更解决了文件名索引验证对内部数据源使用过于严格的关键问题。之前, FSMonitorWorker使用dfm-search的就绪搜索检查,在正常索引维护操作期间阻止 了快速目录扫描。新的验证区分了搜索就绪性(供外部消费者使用)和数据源可用 性(供内部操作使用),允许在恢复/重建更新和积压条件下继续索引操作,同时 在索引真正不可用时仍然阻止。 Log: 优化文件名索引验证,提升维护操作期间的性能表现 Influence: 1. 测试索引处于各种状态(创建中、更新中、已禁用、积压超过限制)时的快速 目录扫描行为 2. 验证用户启用/禁用功能是否正确设置和持久化禁用标志 3. 测试在更新操作期间创建的目录是否仍能被正确监视 4. 验证在updateInProgress和backlogExceeded状态下索引是否继续正常工作 5. 测试索引在状态文件损坏或缺失时的可用性
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's GuideRefines filename-index validation by allowing internal watch seeding and enumeration to use substantially complete indexes during maintenance or backlog conditions, while blocking genuinely unusable or user-disabled indexes. Explicit user enable/disable intent is now persisted in status.json, with accompanying unit tests for validation and state persistence. Sequence diagram for fast directory scan validationsequenceDiagram
participant W as FSMonitorWorker
participant U as IndexUtility
participant P as IndexProfile
participant S as IndexStateStore
W->>U: isFileNameIndexUsableAsDataSource()
U->>P: filename()
U->>P: isIndexAvailable()
U->>S: isCompatibleVersion()
U->>S: getLastUpdateTime()
U->>S: isCreateInProgress()
U->>S: isDisabled()
alt usable data source
U-->>W: true
W->>W: Fast directory scan
else unavailable, unbuilt, creating, or disabled
U-->>W: false
W->>W: Fallback traversal
end
Sequence diagram for persistent filename index enablementsequenceDiagram
actor User
participant D as FileNameIndexDBus
participant S as IndexStateStore
participant F as FSEventController
User->>D: SetEnabled(enabled)
D->>S: isDisabled()
alt enablement intent changed
D->>S: setDisabled(!enabled)
S->>S: Persist disabled in status.json
end
D->>F: setEnabled(enabled)
Flow diagram for filename index data-source validationflowchart TD
A[Internal watch seeding or file enumeration] --> B["isFileNameIndexUsableAsDataSource()"]
B --> C{Index available and compatible}
C -->|No| D[Fallback traversal]
C -->|Yes| E{Built and not creating}
E -->|No| D
E -->|Yes| F{User disabled}
F -->|Yes| D
F -->|No| G[Use filename index as data source]
G --> H[Allow updateInProgress or backlogExceeded]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto reviewAI 代码审查报告
总体评价总分: 97/100 — 优秀 本次 PR 优化了文件名索引数据源验证逻辑,将 四维度评分
维度1:语法逻辑(25/25)✓
变更分析
结论无编译错误,无逻辑缺陷,边界处理完善。 维度2:代码质量(25/25)✓
优点
维度3:代码性能(17/20)✓
性能问题
说明
维度4:代码安全(30/30)✓
安全审查
扫描器误报说明安全扫描器在
漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个 改进建议1. 性能优化:减少重复文件读取(轻微)文件: 当前实现通过 4 个 2. 可读性优化:SetEnabled 条件表达式(轻微)文件: 当前条件 const bool desiredDisabled = !enabled;
if (d->runtime->stateStore().isDisabled() != desiredDisabled) {
d->runtime->stateStore().setDisabled(desiredDisabled);
}审查结论本次 PR 是一次高质量的功能优化,核心变更是将文件名索引验证从"搜索就绪性"细化为"数据源可用性",允许索引在恢复/重建更新期间继续支持快速目录扫描。新增的 建议: 可以合并,建议考虑上述性能优化建议。 |
523b104
into
linuxdeepin:develop/snipe-20260923
isFileNameIndexUsableAsDataSource() method
The changes address a critical issue where the filename index validation was too strict for internal data source usage. Previously, the FSMonitorWorker used dfm-search's ready-for-search check which blocked fast directory scanning during normal index maintenance operations. The new validation distinguishes between search readiness (for external consumers) and data source usability (for internal operations), allowing index operations to continue during recovery/rebuild updates and backlog conditions while still blocking when the index is truly unusable.
Log: Refined filename index validation for better performance during maintenance operations
Influence:
feat: 优化文件名索引数据源验证逻辑
这些变更解决了文件名索引验证对内部数据源使用过于严格的关键问题。之前,
FSMonitorWorker使用dfm-search的就绪搜索检查,在正常索引维护操作期间阻止
了快速目录扫描。新的验证区分了搜索就绪性(供外部消费者使用)和数据源可用
性(供内部操作使用),允许在恢复/重建更新和积压条件下继续索引操作,同时
在索引真正不可用时仍然阻止。
Log: 优化文件名索引验证,提升维护操作期间的性能表现
Influence:
Summary by Sourcery
Refine filename-index validation so internal data-source consumers can use partially stale indexes without unnecessary filesystem-wide fallback scans.
New Features:
Bug Fixes:
Enhancements:
Tests: