Skip to content

fix: treat system-directory apps as pre-installed when InstalledTime is missing - #380

Draft
18202781743 wants to merge 1 commit into
masterfrom
agent/bot/d1de48ec
Draft

fix: treat system-directory apps as pre-installed when InstalledTime is missing#380
18202781743 wants to merge 1 commit into
masterfrom
agent/bot/d1de48ec

Conversation

@18202781743

@18202781743 18202781743 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

问题背景

卸载应用程序后执行"恢复出厂设置",恢复完成后已卸载的应用程序仍出现在启动器的"最近安装"列表中。

根因

dde-application-managerApplicationService 构造函数中,当 firstLaunch == falseInstalledTime 记录缺失(null)时,原逻辑无条件设为当前时间戳。恢复出厂设置后,不可变系统 base 层恢复了预装应用的 desktop 文件,但 storage.json(位于 ~/.local/share/)被保留,导致这些应用被误判为"最近安装"。

修复方案

  • 新增辅助函数 isFromSystemApplicationsDir():遍历 getApplicationsDirs() 返回的目录列表,排除以 getXDGDataHome() 开头的用户级目录,判断 desktop 来源路径是否属于系统级目录。
  • 修改 InstalledTime 为 null 的分支:系统级目录应用 InstalledTime = 0(视为预装),用户级目录应用设为当前时间戳(行为不变)。

改动文件

  • src/dbus/applicationservice.cpp

关联

Summary by Sourcery

Bug Fixes:

  • Prevent previously uninstalled system applications from reappearing in the launcher’s recent installs list after a factory reset by treating them as pre-installed when InstalledTime is absent.

…is missing

When firstLaunch is false and InstalledTime record is null (e.g. after
factory reset restores a pre-installed app's desktop file while
storage.json is preserved), the old code unconditionally set
InstalledTime to the current timestamp, causing uninstalled-and-restored
pre-installed apps to incorrectly appear in the 'recently installed'
list.

Add helper isFromSystemApplicationsDir() to check whether the desktop
source path belongs to a system-level applications directory (excluding
user-level XDG_DATA_HOME). System-level apps now get InstalledTime = 0
(treated as pre-installed); user-level apps keep the current timestamp
behavior.

PMS: BUG-308223
Multica: https://agent-dev.uniontech.com/dde/issues/7c6f66c7-a8af-46c1-b59f-bed257e5e6d5
@deepin-ci-robot

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743

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 Aug 13, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR adjusts how InstalledTime is initialized for applications whose desktop files originate from system-level application directories, so that system apps without an InstalledTime are treated as pre-installed instead of recently installed, and adds a helper to detect system vs user application directories.

File-Level Changes

Change Details Files
Introduce a helper to detect whether a desktop file originates from a system-level applications directory and use it to set InstalledTime to 0 for such apps when the stored InstalledTime is missing.
  • Add static helper function that normalizes the desktop source path, iterates application directories, skips user-level directories based on XDG data home, and checks for system-level directory prefix match.
  • Update ApplicationService constructor logic for null InstalledTime to assign 0 for system-directory apps and current timestamp for user-directory apps, preserving existing behavior for user-installed apps.
  • Maintain existing error handling for storage failures while basing InstalledTime initialization on the new system-directory detection.
src/dbus/applicationservice.cpp

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

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.

2 participants