Skip to content

fix: Failed to save the new file#162

Merged
lzwind merged 2 commits intolinuxdeepin:develop/snipefrom
Kakueeen:develop/snipe
Jul 3, 2025
Merged

fix: Failed to save the new file#162
lzwind merged 2 commits intolinuxdeepin:develop/snipefrom
Kakueeen:develop/snipe

Conversation

@Kakueeen
Copy link
Copy Markdown
Contributor

@Kakueeen Kakueeen commented Jul 3, 2025

Implemented checkAndBuildPath and extractSuffix methods to ensure selected file paths are valid and to append the appropriate suffix based on the selected name filter. Updated the file selection logic to utilize these new methods for improved user experience.

Log: fix bug
Bug: https://pms.uniontech.com/bug-view-322283.html

Summary by Sourcery

Ensure valid file paths by automatically appending the appropriate extension based on the selected name filter during file selection.

Bug Fixes:

  • Fix failure to save new files without explicit extensions

Enhancements:

  • Introduce checkAndBuildPath (using extractSuffix) to validate file paths and append missing extensions

Implemented checkAndBuildPath and extractSuffix methods to ensure selected file paths are valid and to append the appropriate suffix based on the selected name filter. Updated the file selection logic to utilize these new methods for improved user experience.

Log: fix bug
Bug: https://pms.uniontech.com/bug-view-322283.html
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Jul 3, 2025

Reviewer's Guide

This PR introduces helper methods to validate and append missing file suffixes based on the selected name filter, and integrates these methods into the file selection logic for more robust path handling.

Sequence diagram for file selection and path validation

sequenceDiagram
    actor User
    participant FileSelectDialog
    participant FileHander
    User->>FileSelectDialog: Select file and confirm
    FileSelectDialog->>FileSelectDialog: checkAndBuildPath(selectedFile)
    FileSelectDialog->>FileSelectDialog: extractSuffix(selectedNameFilter)
    FileSelectDialog->>FileHander: isLegalFile(path)
    FileHander-->>FileSelectDialog: result
    FileSelectDialog-->>User: Proceed or show warning
Loading

Class diagram for updated FileSelectDialog methods

classDiagram
    class FileSelectDialog {
        +QString checkAndBuildPath(const QString &path)
        +QString extractSuffix(const QString &filter)
        -void saveSetting()
        -QString _resultFile
    }
Loading

File-Level Changes

Change Details Files
Integrate new helpers into file selection flow
  • Use checkAndBuildPath to process the selected file path before validation
  • Log the adjusted path and continue existing legality check
src/frame/cmultiptabbarwidget.cpp
Add helper methods for path validation and suffix extraction
  • Implement checkAndBuildPath to append suffix when missing
  • Implement extractSuffix with regex to parse the selectedNameFilter
  • Declare both methods in the dialog header
src/frame/cmultiptabbarwidget.cpp
src/frame/cmultiptabbarwidget.h

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

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jul 3, 2025

TAG Bot

TAG: 6.5.21
EXISTED: no
DISTRIBUTION: unstable

update version

Log: update version
@deepin-ci-robot
Copy link
Copy Markdown

deepin pr auto review

代码审查意见:

  1. checkAndBuildPath函数中,对于suffix为空的情况,直接返回原路径,这可能不是预期的行为。建议添加日志或抛出异常,以便于调试和追踪问题。

  2. extractSuffix函数中的正则表达式R"(\(([^)]+)\))"可能无法正确匹配所有情况,特别是在过滤条件中包含特殊字符时。建议对输入进行更严格的验证,并考虑使用更健壮的解析方法。

  3. extractSuffix函数中的QStringList suffixList = suffixes.split(' ', Qt::SkipEmptyParts);假设了过滤条件中的后缀是以空格分隔的,如果过滤条件中包含其他分隔符,可能会导致解析错误。建议明确指定分隔符,或者使用更灵活的解析方法。

  4. checkAndBuildPath函数中,如果selectedNameFilter()返回的过滤条件不包含后缀,则直接返回原路径,这可能不是预期的行为。建议添加日志或抛出异常,以便于调试和追踪问题。

  5. checkAndBuildPath函数和extractSuffix函数中的错误处理机制不够完善,建议添加更多的错误处理逻辑,以确保程序的健壮性。

  6. checkAndBuildPath函数和extractSuffix函数的命名不够直观,建议使用更具描述性的命名,以便于其他开发者理解函数的用途。

  7. checkAndBuildPath函数和extractSuffix函数中的正则表达式和字符串操作可能会影响性能,特别是在处理大量文件时。建议对这些操作进行优化,以提高程序的性能。

  8. checkAndBuildPath函数和extractSuffix函数中的错误处理机制不够完善,建议添加更多的错误处理逻辑,以确保程序的健壮性。

  9. checkAndBuildPath函数和extractSuffix函数中的日志输出不够详细,建议添加更多的日志信息,以便于调试和追踪问题。

  10. checkAndBuildPath函数和extractSuffix函数中的错误处理机制不够完善,建议添加更多的错误处理逻辑,以确保程序的健壮性。

@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Kakueeen, lzwind

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

@lzwind lzwind merged commit 4a73293 into linuxdeepin:develop/snipe Jul 3, 2025
15 checks passed
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