Skip to content

Conversation

@wangrong1069
Copy link
Contributor

@wangrong1069 wangrong1069 commented Sep 2, 2025

Summary by Sourcery

Improve pinyin handling, refactor index preparation logic, and centralize file path definitions to enhance indexing and file monitoring robustness.

Enhancements:

  • Convert file name pinyin fields to lowercase and enable analyzed indexing
  • Strip whitespace from full and acronym pinyin outputs
  • Extract and simplify index entry point setup into a helper with directory existence checks and enhanced error handling
  • Introduce a macro for the VFS unnamed device file path and replace hardcoded strings

- Introduced a constant for the unnamed device file path to improve code readability and maintainability.
- Updated file operations to use the new constant instead of hardcoded strings.

Log: Refactor VFS unnamed device file handling
- Modified the pinyin processing to remove spaces from the full pinyin and acronym outputs.
- Updated the document creation process to convert pinyin fields to lowercase and set them as indexed for improved searchability.

Log: Update pinyin processing and indexing
As title.

Log: Fix fail to create symbolic links for index entry point
As title.

Log: Update version to 7.0.26
@github-actions
Copy link

github-actions bot commented Sep 2, 2025

TAG Bot

TAG: 7.0.26
EXISTED: no
DISTRIBUTION: unstable

@sourcery-ai
Copy link

sourcery-ai bot commented Sep 2, 2025

Reviewer's Guide

This PR enhances pinyin field handling by normalizing case and tokenization, refactors index preparation into a dedicated entry point creator with robust directory and symlink management, trims whitespace in processed pinyin, and centralizes the VFS unnamed device file path in the server main.

Class diagram for updated pinyin_processor and file_index_manager

classDiagram
    class pinyin_processor {
        +void convert_to_pinyin(const std::string& sentence, std::string& pinyin_full, std::string& pinyin_acronym)
        +unsigned int hex_to_dec(const std::string& hex_str)
    }
    class file_index_manager {
        +void prepare_index()
        +void try_refresh_reader(bool nrt)
    }
    class create_index_entry_point {
        +static void create_index_entry_point(const std::string &volatile_index_directory)
    }
    file_index_manager --> create_index_entry_point : calls
Loading

Flow diagram for improved index entry point creation

flowchart TD
    A[prepare_index called] --> B[create_index_entry_point called]
    B --> C{volatile_index_directory == index_entry_point?}
    C -- Yes --> D[Return]
    C -- No --> E[Remove index entry point symlink]
    E --> F{volatile_index_directory exists?}
    F -- No --> G[Create volatile_index_directory]
    G --> H[Check for errors]
    F -- Yes --> I[Create symlink from volatile_index_directory to index_entry_point]
    H --> I
    I --> J[Check for errors]
    J --> K[Exit on error]
Loading

File-Level Changes

Change Details Files
Normalize and tokenize pinyin fields in Lucene documents
  • Apply StringUtils::toLower to pinyin and acronym values
  • Change Field index mode from INDEX_NOT_ANALYZED to INDEX_ANALYZED
src/daemon/src/core/file_index_manager.cpp
Extract and harden index entry point setup logic
  • Introduce static create_index_entry_point function for symlink management
  • Remove existing entry point before creating new symlink
  • Ensure volatile directory exists or create it with error checks
  • Log and exit on filesystem errors
src/daemon/src/core/file_index_manager.cpp
Trim whitespace from generated pinyin strings
  • Use remove_if with isspace to erase spaces in pinyin_full
  • Use remove_if with isspace to erase spaces in pinyin_acronym
src/daemon/src/core/pinyin_processor.cpp
Centralize VFS unnamed device file path in server main
  • Define VFS_UNNAMED_DEVICE_FILE macro
  • Replace literal file path with macro in fopen and g_file_get_contents calls
src/server/main.c

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • The helper create_index_entry_point unconditionally calls exit on failure—consider returning an error status or throwing an exception instead so callers can handle failures gracefully and improve testability.
  • You switched the pinyin fields to lowercase and indexed them as ANALYZED; double-check and update any downstream query/analyzer logic to ensure search behavior still works as expected.
  • The VFS_UNNAMED_DEVICE_FILE macro in main.c might be better placed in a shared header (or clearly documented) to avoid duplicating the path literal if it’s used elsewhere.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The helper create_index_entry_point unconditionally calls exit on failure—consider returning an error status or throwing an exception instead so callers can handle failures gracefully and improve testability.
- You switched the pinyin fields to lowercase and indexed them as ANALYZED; double-check and update any downstream query/analyzer logic to ensure search behavior still works as expected.
- The VFS_UNNAMED_DEVICE_FILE macro in main.c might be better placed in a shared header (or clearly documented) to avoid duplicating the path literal if it’s used elsewhere.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot
Copy link

[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.

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

@wangrong1069
Copy link
Contributor Author

/forcemerge

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Sep 2, 2025

This pr force merged! (status: unstable)

@deepin-bot deepin-bot bot merged commit e14c08a into linuxdeepin:develop/snipe Sep 2, 2025
16 of 18 checks passed
@wangrong1069 wangrong1069 deleted the pr0829-2 branch September 2, 2025 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants