Skip to content

feat: add user-level desktop file handling in uninstaller#49

Closed
wjyrich wants to merge 1 commit into
linuxdeepin:masterfrom
wjyrich:fix-bug-315791
Closed

feat: add user-level desktop file handling in uninstaller#49
wjyrich wants to merge 1 commit into
linuxdeepin:masterfrom
wjyrich:fix-bug-315791

Conversation

@wjyrich

@wjyrich wjyrich commented Jul 23, 2025

Copy link
Copy Markdown
Contributor
  1. Added special handling for user-level desktop files (in ~/.local/ share/applications/)
  2. Automatically removes both the desktop file and associated icon if found
  3. Provides clear success/error messages for user feedback
  4. Maintains existing system-wide desktop file handling logic
  5. Improves cleanup of user-installed applications

feat: 在卸载程序中添加用户级桌面文件处理

  1. 添加了对用户级桌面文件(位于~/.local/share/applications/)的特殊处理
  2. 自动删除桌面文件及关联图标(如果找到)
  3. 提供清晰的成功/错误信息作为用户反馈
  4. 保留现有的系统级桌面文件处理逻辑
  5. 改进用户安装应用程序的清理工作

Pms: BUG-315791

Summary by Sourcery

Add special handling to the uninstaller for user-level desktop files by detecting and removing them along with any associated icons, while preserving existing system-wide logic and enhancing cleanup of user-installed applications

New Features:

  • Detect and remove user-level desktop files under ~/.local/share/applications
  • Automatically remove associated icon files referenced in the desktop file
  • Display clear success and error messages during user-level file removal

Enhancements:

  • Retain existing system-wide desktop file handling logic
  • Improve cleanup of user-installed applications

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: wjyrich

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

@sourcery-ai

sourcery-ai Bot commented Jul 23, 2025

Copy link
Copy Markdown

Reviewer's Guide

Extend the uninstaller script to detect and clean up user-level .desktop entries in ~/.local/share/applications, removing both the desktop file and any referenced icon with clear exit codes, while preserving existing system-wide logic.

Sequence diagram for user-level desktop file uninstallation

sequenceDiagram
    actor User
    participant Uninstaller as dde-appwiz-uninstaller.sh
    participant FileSystem
    User->>Uninstaller: Run uninstaller with user-level .desktop file path
    Uninstaller->>Uninstaller: Detect user-level desktop file
    Uninstaller->>FileSystem: Read Icon path from .desktop file
    Uninstaller->>FileSystem: Remove .desktop file
    alt .desktop file removed successfully
        Uninstaller->>FileSystem: Remove associated icon (if exists)
        alt Icon removed
            Uninstaller->>User: Success message for desktop file and icon
        else Icon not removed
            Uninstaller->>User: Warning message for icon
        end
    else .desktop file removal failed
        Uninstaller->>User: Error message
    end
Loading

File-Level Changes

Change Details Files
Detect and remove user-level desktop files
  • Added pattern check for ~/.local/share/applications in the script
  • Attempt to remove the .desktop file and exit early on success/failure
scripts/dde-appwiz-uninstaller.sh
Extract and clean up associated icons
  • Parse Icon path from the .desktop file using grep and cut
  • Check if the icon path is a file and remove it, handling removal errors
scripts/dde-appwiz-uninstaller.sh
Provide clear user feedback
  • Echo messages on detection, removal success, warnings, and errors
  • Use exit codes (0/1) to signal overall success or failure
scripts/dde-appwiz-uninstaller.sh

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

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey @wjyrich - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `scripts/dde-appwiz-uninstaller.sh:20` </location>
<code_context>
+    echo "Detected user-level desktop file: '$DESKTOP_FILE_PATH'"
+    
+    # Read the Icon path from the desktop file
+    ICON_PATH=$(grep "^Icon=" "$DESKTOP_FILE_PATH" 2>/dev/null | cut -d'=' -f2-)
+    
+    # For user-level desktop files, just remove the file
</code_context>

<issue_to_address>
Parsing the Icon path may not handle icon themes or relative paths.

The code assumes the Icon entry is a direct file path, but it may be a theme icon name or relative path. Please add logic to handle these cases or document this limitation.
</issue_to_address>

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.

Comment thread scripts/dde-appwiz-uninstaller.sh Outdated
echo "Detected user-level desktop file: '$DESKTOP_FILE_PATH'"

# Read the Icon path from the desktop file
ICON_PATH=$(grep "^Icon=" "$DESKTOP_FILE_PATH" 2>/dev/null | cut -d'=' -f2-)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Parsing the Icon path may not handle icon themes or relative paths.

The code assumes the Icon entry is a direct file path, but it may be a theme icon name or relative path. Please add logic to handle these cases or document this limitation.

@BLumia BLumia left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

浏览器快捷方式的卸载不要走卸载系统软件包的逻辑,毕竟实质上不是一回事。

可以单独加逻辑对浏览器创建的网页快捷方式进行卸载(仅能匹配限定的几个主流浏览器就行),或者暂时搁置这个需求后续我来搞。

1. Added recursive symlink resolution with loop detection for desktop
files
2. Implemented special handling for Chrome PWA applications
3. Added cleanup of associated icon files when uninstalling Chrome PWAs
4. Improved error handling and debug logging
5. Added QSet include for tracking visited symlink paths

The changes address two main issues:
1. Symlinks to desktop files weren't being properly resolved, which
could cause uninstallation failures
2. Chrome Progressive Web Apps created special desktop entries that
needed custom uninstallation logic
The new symlink resolution handles nested symlinks safely while
preventing infinite loops, and the Chrome PWA handling ensures proper
cleanup of both desktop entries and their icons.

fix: 改进符号链接解析和 Chrome PWA 处理

1. 为桌面文件添加了带循环检测的递归符号链接解析
2. 实现了对 Chrome PWA 应用的特殊处理
3. 卸载 Chrome PWA 时添加了关联图标文件的清理
4. 改进了错误处理和调试日志
5. 添加了 QSet 包含用于跟踪访问过的符号链接路径

这些更改解决了两个主要问题:
1. 桌面文件的符号链接未被正确解析,可能导致卸载失败
2. Chrome 渐进式网页应用创建的特殊桌面条目需要自定义卸载逻辑
新的符号链接解析功能安全地处理嵌套符号链接同时防止无限循环,而 Chrome
PWA 处理确保正确清理桌面条目及其关联图标

Pms: BUG-315791
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

关键摘要:

  • 在处理符号链接时,使用了QSet来防止无限循环,这是一个好的做法。
  • 在处理Chrome PWA应用时,添加了详细的日志输出,有助于调试。
  • 在删除文件时,没有检查文件是否成功删除,可能会导致后续操作失败。

是否建议立即修改:

建议的修改:

  • 在删除文件后,应该检查文件是否成功删除,并处理可能的错误情况。
  • 对于Chrome PWA应用的卸载处理,应该添加更多的错误处理逻辑,例如检查文件路径是否有效等。
  • 在处理符号链接时,可以考虑使用QDircanonicalFilePath()方法来简化代码,并避免手动实现循环检测。
  • 对于日志输出,应该考虑使用更通用的日志级别,而不是总是使用qDebug(),以便于在生产环境中进行日志管理。
  • 在处理Chrome PWA应用时,应该添加对Exec字段中可能存在的其他浏览器(如Firefox)的支持,以保持代码的通用性。

@deepin-bot

deepin-bot Bot commented Aug 21, 2025

Copy link
Copy Markdown

TAG Bot

New tag: 0.1.19
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #52

@deepin-bot

deepin-bot Bot commented Aug 28, 2025

Copy link
Copy Markdown

TAG Bot

New tag: 0.1.20
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #55

@deepin-bot

deepin-bot Bot commented Sep 25, 2025

Copy link
Copy Markdown

TAG Bot

New tag: 0.1.21
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #57

@wjyrich wjyrich closed this Feb 27, 2026
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