Skip to content

fix: ensure directories exist before use and update cover metadata - #735

Open
kt286 wants to merge 1 commit into
linuxdeepin:masterfrom
kt286:split/fix-ensure-dirs-cover-meta
Open

fix: ensure directories exist before use and update cover metadata#735
kt286 wants to merge 1 commit into
linuxdeepin:masterfrom
kt286:split/fix-ensure-dirs-cover-meta

Conversation

@kt286

@kt286 kt286 commented Aug 2, 2026

Copy link
Copy Markdown
Contributor
  • Pre-create config/cache/database directories using QDir::mkpath() to fix build on MSYS2 where directories may not exist yet
  • Simplify directory creation logic in MusicSettings
  • Emit metaChanged signal when cover is ready for current playing media
  • Fetch latest cover/lyric metadata from database in getActivateMeta()

fix: 确保目录在使用前已创建,并修复封面元数据更新

  • 使用 QDir::mkpath() 预创建配置/缓存/数据库目录, 修复 MSYS2 构建时目录不存在的问题
  • 简化 MusicSettings 中的目录创建逻辑
  • 当前播放歌曲的封面就绪时发送 metaChanged 信号
  • 在 getActivateMeta() 中从数据库获取最新的封面和歌词路径

Summary by Sourcery

Ensure application creates required config, cache, and database directories before use and keeps active media cover/lyric metadata in sync with the database.

New Features:

  • Emit metaChanged when the cover for the currently playing media becomes ready to keep the UI in sync with metadata updates.

Bug Fixes:

  • Refresh active media metadata from the database in getActivateMeta to use the latest cover and lyric information.
  • Pre-create application config, cache, and database directories to prevent failures when paths do not yet exist, including on MSYS2 builds.

Enhancements:

  • Simplify directory creation logic in MusicSettings and central path initialization by using QDir::mkpath for required directories.

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

Sorry @kt286, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: kt286

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

@deepin-ci-robot

Copy link
Copy Markdown

Hi @kt286. Thanks for your PR.

I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@sourcery-ai

sourcery-ai Bot commented Aug 2, 2026

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

Reviewer's Guide

Ensures required config/cache/database directories are pre-created using QDir::mkpath, simplifies image directory setup in MusicSettings, and fixes cover/lyric metadata freshness and metaChanged signaling for the currently playing media.

Sequence diagram for updated cover ready signaling and metaChanged emission

sequenceDiagram
    participant DataManager
    participant Presenter
    participant PlayerEngine

    DataManager->>Presenter: signalMetaCoverReady(meta)
    Presenter->>Presenter: emit metaCoverReady(Utils::metaToVariantMap(meta))
    Presenter->>PlayerEngine: getMediaMeta()
    PlayerEngine-->>Presenter: MediaMeta currentMeta
    Presenter-->>Presenter: [currentMeta.hash == meta.hash]
    Presenter->>Presenter: emit metaChanged()
Loading

Sequence diagram for getActivateMeta fetching freshest cover and lyric metadata

sequenceDiagram
    participant Presenter
    participant PlayerEngine
    participant DataManager

    Presenter->>Presenter: getActivateMeta()
    Presenter->>PlayerEngine: getMediaMeta()
    PlayerEngine-->>Presenter: MediaMeta meta
    Presenter-->>Presenter: [!meta.hash.isEmpty()]
    Presenter->>DataManager: metaFromHash(meta.hash)
    DataManager-->>Presenter: MediaMeta latestMeta
    Presenter-->>Presenter: [!latestMeta.hash.isEmpty()]
    Presenter-->>Presenter: update meta.coverUrl, meta.hasimage, meta.lyricPath
    Presenter->>Presenter: Utils::metaToVariantMap(meta)
Loading

File-Level Changes

Change Details Files
Emit metaChanged when the current track’s cover metadata becomes ready and ensure getActivateMeta returns up-to-date cover/lyric info from the database.
  • Connect DataManager::signalMetaCoverReady handler to emit metaChanged when the ready cover’s hash matches the currently playing media’s hash.
  • Update getActivateMeta to start from the player engine’s current MediaMeta, then refresh coverUrl/hasimage/lyricPath from DataManager::metaFromHash when available.
  • Return the refreshed MediaMeta via Utils::metaToVariantMap instead of the raw engine meta.
src/libdmusic/presenter.cpp
Simplify cover image directory creation in MusicSettings and ensure the config path exists before using the settings backend.
  • Replace manual images directory creation logic with a single QDir::mkpath call on cachePath()/images.
  • Create the parent directory for config.ini via QDir::mkpath(QFileInfo(configFilepath).absolutePath()) before initializing QSettingBackend.
src/libdmusic/core/musicsettings.cpp
Guarantee database and global user config/cache directories exist before opening the SQLite DB or using paths, improving robustness on platforms like MSYS2.
  • Include QDir in DataManager implementation to support directory creation.
  • Before opening the SQLite database, call QDir::mkpath on QFileInfo(dbPath).absolutePath() to ensure the DB directory exists.
  • In DmGlobal::initPath, call QDir::mkpath on userConfigPath and userCachePath immediately after resolving them from DStandardPaths.
src/libdmusic/core/datamanager.cpp
src/libdmusic/global.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

@kt286
kt286 force-pushed the split/fix-ensure-dirs-cover-meta branch 3 times, most recently from ab61c45 to 3f45822 Compare August 5, 2026 01:40
- Pre-create config/cache/database directories using QDir::mkpath()
  to fix build on MSYS2 where directories may not exist yet
- Simplify directory creation logic in MusicSettings
- Emit metaChanged signal when cover is ready for current playing media
- Fetch latest cover/lyric metadata from database in getActivateMeta()

fix: 确保目录在使用前已创建,并修复封面元数据更新

- 使用 QDir::mkpath() 预创建配置/缓存/数据库目录,
  修复 MSYS2 构建时目录不存在的问题
- 简化 MusicSettings 中的目录创建逻辑
- 当前播放歌曲的封面就绪时发送 metaChanged 信号
- 在 getActivateMeta() 中从数据库获取最新的封面和歌词路径
@kt286
kt286 force-pushed the split/fix-ensure-dirs-cover-meta branch from 3f45822 to ac5224d Compare August 5, 2026 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants