Skip to content

fix: Update file path handling in saveAsFileToDisk function#374

Merged
lzwind merged 2 commits intolinuxdeepin:masterfrom
dengzhongyuan365-dev:master
Jul 18, 2025
Merged

fix: Update file path handling in saveAsFileToDisk function#374
lzwind merged 2 commits intolinuxdeepin:masterfrom
dengzhongyuan365-dev:master

Conversation

@dengzhongyuan365-dev
Copy link
Contributor

@dengzhongyuan365-dev dengzhongyuan365-dev commented Jul 18, 2025

fix: Update file path handling in saveAsFileToDisk function

  • Save the original file path before updating to prevent premature checks on file existence.
  • Update the file path only after a successful save to ensure accuracy.

log: Update file path handling in saveAsFileToDisk function

bug: https://pms.uniontech.com/bug-view-322759.html

Summary by Sourcery

Correct saveAsFileToDisk logic to hold the original file path during saving and only update it after a successful write; adjust related path‐update call to use the preserved old path.

Bug Fixes:

  • Delay updating the wrapper’s file path until after a successful save to prevent premature existence checks

Enhancements:

  • Bump deepin-editor package version to 6.5.32.1 and switch linglong.yaml source URL to crimson_25.0

- Save the original file path before updating to prevent premature checks on file existence.
- Update the file path only after a successful save to ensure accuracy.

log: Update file path handling in saveAsFileToDisk function

bug: https://pms.uniontech.com/bug-view-322759.html
- Updated version to 6.5.32 in all architecture-specific linglong.yaml files.
- Changed package source URLs from testing25_daily to crimson_25.0 for consistency across architectures.

log: Update version and package URLs in linglong.yaml files
@github-actions
Copy link

TAG Bot

TAG: 6.5.32
EXISTED: no
DISTRIBUTION: unstable

@sourcery-ai
Copy link

sourcery-ai bot commented Jul 18, 2025

Reviewer's Guide

This PR refactors the saveAsFileToDisk logic to cache the original file path and defer path updates until after a successful save, and bumps the package version and source URLs in the build metadata.

Sequence diagram for updated saveAsFileToDisk file path handling

sequenceDiagram
    participant User
    participant Window
    participant Wrapper
    participant Settings
    participant FileSystem
    User->>Window: Trigger saveAsFileToDisk()
    Window->>Wrapper: filePath()
    Window->>Settings: setSavePath(LastOptBox, newFilePath)
    Window->>Settings: setSavePath(CurFileBox, newFilePath)
    Window->>Wrapper: filePath() (store as oldFilePath)
    Window->>FileSystem: Check if file exists
    alt File exists
        Window->>Wrapper: saveFile(newFilePath, encode)
    else File does not exist
        Window->>Wrapper: saveFile(newFilePath, encode)
    end
    alt Save successful
        Window->>Wrapper: updatePath(oldFilePath, newFilePath)
        Window->>Wrapper: bottomBar().setEncodeName(encode)
        Window->>Window: updateSaveAsFileName(oldFilePath, newFilePath)
        Window-->>User: Return newFilePath
    else Save failed
        Window-->>User: Return empty string
    end
Loading

Class diagram for updated saveAsFileToDisk logic

classDiagram
    class Window {
        +QString saveAsFileToDisk()
        -void updateSaveAsFileName(QString oldFilePath, QString newFilePath)
    }
    class Wrapper {
        +QString filePath()
        +void updatePath(QString oldFilePath, QString newFilePath)
        +QByteArray getTextEncode()
        +BottomBar* bottomBar()
        +bool saveFile(QString filePath, QByteArray encode)
    }
    class Settings {
        +void setSavePath(int boxType, QString path)
    }
    class BottomBar {
        +void setEncodeName(QByteArray encode)
    }
    Window --> Wrapper
    Window --> Settings
    Wrapper --> BottomBar
Loading

File-Level Changes

Change Details Files
Refactor saveAsFileToDisk to defer path updates
  • Capture original file path in oldFilePath before saving
  • Remove early wrapper->updatePath call prior to actual file write
  • Invoke wrapper->updatePath(oldFilePath, newFilePath) only after successful save
  • Adjust updateSaveAsFileName to use oldFilePath instead of wrapper->filePath()
src/widgets/window.cpp
Bump package version and update source URLs
  • Increment package version from 6.5.31.1 to 6.5.32.1
  • Replace testing25_daily source URLs with crimson_25.0 URLs
linglong.yaml

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

@deepin-ci-robot
Copy link

deepin pr auto review

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 @dengzhongyuan365-dev - I've reviewed your changes and they look great!


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: dengzhongyuan365-dev, 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 bad415a into linuxdeepin:master Jul 18, 2025
19 of 21 checks passed
@github-actions
Copy link

  • 敏感词检查失败, 检测到1个文件存在敏感词
详情
{
    "src/widgets/window.cpp": [
        {
            "line": "    QString key = \"base/enable\";",
            "line_number": 387,
            "rule": "S106",
            "reason": "Var naming | 64f28539d9"
        }
    ]
}

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