fix(linglong): add apps/share path to XDG_DATA_DIRS - #598
Merged
Conversation
wyu71
force-pushed
the
master
branch
6 times, most recently
from
March 18, 2026 04:34
3140b10 to
67ed018
Compare
Add /run/host/rootfs/var/lib/linglong/entries/apps/share to XDG_DATA_DIRS for searching help manuals in linglong apps directory. 在 XDG_DATA_DIRS 中添加玲珑 apps 目录,支持搜索玲珑应用帮助手册。 Log: 添加玲珑 apps 目录到 XDG_DATA_DIRS PMS: BUG-353341 Influence: 玲珑环境下可搜索 entries/apps/share 目录中的帮助手册。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
deepin pr auto review这段代码的 diff 主要改进了对 1. 语法逻辑
2. 代码质量
3. 代码性能
4. 代码安全
总结与改进建议代码总体来说,这是一次高质量的代码重构。为了进一步完善,建议做以下微调:
修改建议代码片段: // ... (前文代码)
bool isLinglong = qEnvironmentVariableIsSet(ENV_LINGLONG_APPID);
if (isLinglong) {
qInfo() << "Linglong environment detected";
QByteArray rawEnv = qgetenv(ENV_XDG_DATA_DIRS);
QStringList pathList;
if (!rawEnv.isEmpty()) {
QString paths = QString::fromUtf8(rawEnv);
// 改进:如果 UTF-8 转换失败,尝试使用本地编码作为回退,而不是直接丢弃
if (paths.toUtf8() != rawEnv) {
qWarning() << "XDG_DATA_DIRS contains invalid UTF-8, trying local encoding.";
paths = QString::fromLocal8Bit(rawEnv);
}
// 只有在转换后的字符串非空时才进行分割
if (!paths.isEmpty()) {
pathList = paths.split(':', Qt::SkipEmptyParts);
}
}
// 改进:使用 QSet 去重,然后再转回 QStringList(如果路径顺序不重要)
// 或者保持原样,因为 QStringList::contains 对于少量数据足够快
QSet<QString> pathSet = pathList.toSet();
// 添加新路径,QSet::insert 会自动处理重复
for (const QString &extraPath : LINGLONG_EXTRA_PATHS) {
pathSet.insert(extraPath);
}
// 转回列表并合并
// 注意:Set 是无序的,如果对路径顺序有严格要求(例如优先级),请保持原有的 QStringList + contains 逻辑
pathList = pathSet.values();
if (!pathList.isEmpty()) {
qputenv(ENV_XDG_DATA_DIRS, pathList.join(':').toUtf8());
} else {
// 如果列表为空(例如 rawEnv 为空且转换失败),至少写入 Linglong 的默认路径
qputenv(ENV_XDG_DATA_DIRS, LINGLONG_EXTRA_PATHS.join(':').toUtf8());
}
}
// ... (后文代码)注意:关于 if (!rawEnv.isEmpty()) {
QString paths = QString::fromUtf8(rawEnv);
if (paths.toUtf8() != rawEnv) {
qWarning() << "XDG_DATA_DIRS contains invalid UTF-8, trying local encoding.";
paths = QString::fromLocal8Bit(rawEnv);
}
if (!paths.isEmpty()) {
pathList = paths.split(':', Qt::SkipEmptyParts);
}
}
// 保持原有的 QStringList 逻辑以保证顺序
for (const QString &extraPath : LINGLONG_EXTRA_PATHS) {
if (!pathList.contains(extraPath)) {
pathList.append(extraPath);
}
}
// 确保即使 pathList 为空(极端情况),也能写入 Linglong 路径
if (pathList.isEmpty()) {
pathList = LINGLONG_EXTRA_PATHS;
}
qputenv(ENV_XDG_DATA_DIRS, pathList.join(':').toUtf8()); |
lzwind
approved these changes
Mar 18, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lzwind, wyu71 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add /run/host/rootfs/var/lib/linglong/entries/apps/share to XDG_DATA_DIRS for searching help manuals in linglong apps directory.
在 XDG_DATA_DIRS 中添加玲珑 apps 目录,支持搜索玲珑应用帮助手册。
Log: 添加玲珑 apps 目录到 XDG_DATA_DIRS
PMS: BUG-353341
Influence: 玲珑环境下可搜索 entries/apps/share 目录中的帮助手册。