feat: optimize index initialization with conditional refresh#209
Merged
deepin-bot[bot] merged 6 commits intolinuxdeepin:develop/snipefrom Apr 13, 2026
Merged
feat: optimize index initialization with conditional refresh#209deepin-bot[bot] merged 6 commits intolinuxdeepin:develop/snipefrom
deepin-bot[bot] merged 6 commits intolinuxdeepin:develop/snipefrom
Conversation
There was a problem hiding this comment.
Sorry @wangrong1069, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
Remove the old directory scanning mechanism.
Refactored the index initialization process to conditionally perform full index refresh and scan based on the presence of a refresh_index file. Previously, the system always performed a refresh and scan on startup. Now, it checks for the existence of refresh_index file in the volatile index directory. If the file exists, it performs a full refresh and scan, then deletes the file. If not, it skips the refresh and scan, directly entering monitoring mode. This improves startup performance for normal launches. The timer thread initialization is also delayed until after this conditional logic is evaluated. Copyright headers were updated to the standard SPDX format and consolidated. Method order and visibility were adjusted in headers for clarity. Influence: 1. Test application startup when refresh_index file is present (should trigger full scan) 2. Test application startup when refresh_index file is absent (should skip full scan) 3. Verify that refresh_index file is deleted after a successful refresh and scan 4. Monitor index status transitions to ensure proper state management 5. Test index functionality after both startup paths to ensure data consistency 6. Verify timer thread starts correctly in both scenarios Task: https://pms.uniontech.com/task-view-387601.html feat: 优化索引初始化逻辑,支持按需刷新 重构了索引初始化流程,改为根据 refresh_index 文件的存在条件性地执行完整 的索引刷新和扫描。之前,系统在启动时总是执行刷新和扫描。现在,它会检查 易失性索引目录中是否存在 refresh_index 文件。如果文件存在,则执行完整的 刷新和扫描,然后删除该文件。如果不存在,则跳过刷新和扫描,直接进入监控模 式。这提高了正常启动时的启动性能。定时器线程的初始化也延迟到此条件逻辑评 估之后。更新了版权头信息为标准 SPDX 格式并进行了合并。调整了头文件中的方 法顺序和可见性以提高清晰度。 Influence: 1. 测试当 refresh_index 文件存在时应用程序的启动(应触发完整扫描) 2. 测试当 refresh_index 文件不存在时应用程序的启动(应跳过完整扫描) 3. 验证在成功的刷新和扫描后 refresh_index 文件是否被删除 4. 监控索引状态转换以确保正确的状态管理 5. 测试两种启动路径后的索引功能以确保数据一致性 6. 验证定时器线程在两种场景下是否正确启动 Task: https://pms.uniontech.com/task-view-387601.html
1. Uncommented and implemented the `document_size()` method in `file_index_manager` to return the number of indexed documents 2. Added logic in `base_event_handler` constructor to check if the persisted index is empty 3. When index is empty, creates a `refresh_index` file to trigger a full directory scan on daemon startup 4. This ensures that new installations or cleared indexes will automatically rebuild their search index Log: Added automatic full directory scan trigger when search index is empty Influence: 1. Test fresh installation to verify full directory scan is triggered automatically 2. Test after clearing index data to ensure re-indexing occurs 3. Verify `document_size()` method returns correct counts for both persisted and near real-time indexes 4. Check that the `refresh_index` file is created and removed properly during scan process 5. Monitor system performance during initial full scan of large directories 6. Verify search functionality works correctly after automatic re- indexing Task: https://pms.uniontech.com/task-view-387601.html feat: 实现索引大小检查并在索引为空时触发全盘扫描 1. 取消注释并实现了 `file_index_manager` 中的 `document_size()` 方法,用 于返回已索引文档的数量 2. 在 `base_event_handler` 构造函数中添加了检查持久化索引是否为空的逻辑 3. 当索引为空时,创建 `refresh_index` 文件以在守护进程启动时触发全目录 扫描 4. 这确保了新安装或清除的索引将自动重建其搜索索引 Log: 新增当搜索索引为空时自动触发全目录扫描的功能 Influence: 1. 测试全新安装,验证是否自动触发全目录扫描 2. 测试清除索引数据后,确保重新索引过程正常进行 3. 验证 `document_size()` 方法是否正确返回持久化和近实时索引的文档数量 4. 检查 `refresh_index` 文件在扫描过程中是否正确创建和删除 5. 监控大型目录初始全盘扫描时的系统性能 6. 验证自动重新索引后搜索功能是否正常工作 Task: https://pms.uniontech.com/task-view-387601.html
Added a new running flag module to detect and handle daemon abnormal exits. The module creates a flag file when the daemon starts and removes it on normal shutdown. If the flag file exists on startup, it indicates the previous session ended abnormally (crash or termination). This detection is used to trigger a full directory scan when the daemon restarts after an abnormal exit, ensuring index consistency. The implementation includes: 1. New running_flag.h/cpp files with functions to manage the flag file 2. Integration in main.cpp to set/remove the flag during daemon lifecycle 3. Modified base_event_handler.cpp to check abnormal exit status and trigger refresh 4. Thread-safe operations with mutex protection 5. Automatic directory creation for the flag file Log: Added automatic full scan trigger after daemon crash recovery Influence: 1. Test daemon normal shutdown - verify flag file is removed 2. Simulate daemon crash (kill -9) - verify flag file persists 3. Restart daemon after crash - verify full scan is triggered 4. Test concurrent access scenarios with multiple threads 5. Verify directory creation when volatile index dir doesn't exist 6. Test with insufficient permissions for flag file operations feat: 添加守护进程异常退出检测机制 新增运行标志模块用于检测和处理守护进程异常退出。该模块在守护进程启动时 创建标志文件,在正常关闭时移除。如果启动时标志文件存在,则表明上一次会话 异常结束(崩溃或被终止)。此检测用于在守护进程异常退出后重启时触发全盘扫 描,确保索引一致性。 实现包括: 1. 新增 running_flag.h/cpp 文件,包含管理标志文件的函数 2. 在 main.cpp 中集成,在守护进程生命周期内设置/移除标志 3. 修改 base_event_handler.cpp 以检查异常退出状态并触发刷新 4. 线程安全操作,包含互斥锁保护 5. 自动创建标志文件所需的目录 Log: 新增守护进程崩溃恢复后自动触发全盘扫描功能 Influence: 1. 测试守护进程正常关闭 - 验证标志文件被移除 2. 模拟守护进程崩溃 (kill -9) - 验证标志文件仍然存在 3. 崩溃后重启守护进程 - 验证触发全盘扫描 4. 测试多线程并发访问场景 5. 验证易失性索引目录不存在时的自动创建 6. 测试标志文件操作权限不足的情况
- Add set_refresh_index_flag(), have_refresh_index_flag(), remove_refresh_index_flag() - Encapsulate refresh index flag file operations for better maintainability - Add check for interrupted scan before removing refresh flag Task: https://pms.uniontech.com/task-view-387601.html
deepin-anything-daemon starts automatically by default, so an Install section is not needed. We can control whether it starts automatically via mask/unmask. Task: https://pms.uniontech.com/task-view-387601.html
lzwind
approved these changes
Apr 13, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lzwind, wangrong1069 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 |
Contributor
Author
|
/merge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.