Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,17 @@ bool Utils::isDpkgLocked()

QString Utils::getUrl()
{
// ~/url 文件用于切换驱动查询的环境地址:
// - 文件不存在或不可读时,默认使用生产环境 URL(安全默认)
// - 文件内容为 "true" 时,使用生产环境 URL
// - 文件内容为其他值时,使用预生产环境 URL
// 该设计意图与客户端 commontools.cpp 中 CommonTools::getUrl() 保持一致

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nitpick: The new comment claims this implementation’s design intent remains consistent with CommonTools::getUrl(), but CommonTools::getUrl() does not call trimmed() and has different behavior for whitespace-terminated values. The comment falsely documents cross-component consistency and can mislead future maintainers into assuming the client has the same fix.

Suggested fix: Update the client implementation as well, or change the comment to state that the implementations currently differ.

Suggested change
// 该设计意图与客户端 commontools.cpp 中 CommonTools::getUrl() 保持一致
// 该设计意图与客户端 commontools.cpp 中 CommonTools::getUrl() 当前实现存在差异

QFile file(QDir::homePath() + "/url");
if (!file.open(QIODevice::ReadOnly)) {
return "https://driver.uniontech.com/api/v1/drive/search";
}
QString info = file.readAll();
// trimmed() 去除首尾空白和换行符,确保 "true\n" 等内容能正确匹配 "true"
QString info = file.readAll().trimmed();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (broader_impact): The server now treats "true\n" or other surrounding-whitespace variants as production, while the client’s CommonTools::getUrl() still compares the raw file contents and treats the same file as pre-production. The shared ~/url configuration therefore selects different driver service environments depending on whether the request goes through the server or the client.

Triggers: When ~/url contains true with leading or trailing whitespace, including the documented true\n case.

Suggested fix: Apply the same trimming behavior in deepin-devicemanager/src/Tool/commontools.cpp, or centralize URL selection so both components use the same normalization rule.

if ("true" == info) {
return "https://driver.uniontech.com/api/v1/drive/search";
} else {
Expand Down
Loading