fix(input): create udev rules directory when missing during keyboard …#591
Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom Dec 31, 2025
Merged
fix(input): create udev rules directory when missing during keyboard …#591deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
Conversation
…enable create udev rules directory when missing during keyboard enable or disable log: create udev rules directory bug: https://pms.uniontech.com/bug-view-346127.html
Reviewer's guide (collapsed on small PRs)Reviewer's GuideUpdates keyboard enable logic to automatically create the udev rules directory if it is missing, adding info/warning logs and only failing when directory creation itself fails. Sequence diagram for updated keyboard enable udev rules directory handlingsequenceDiagram
participant ControlInterface
participant QFileInfo
participant QDir
participant Logger
ControlInterface->>QFileInfo: QFileInfo(rulesFile)
QFileInfo-->>ControlInterface: fileInfo
ControlInterface->>QDir: QDir rulesDir = fileInfo.absoluteDir()
ControlInterface->>QDir: rulesDir.exists()
QDir-->>ControlInterface: exists
alt rulesDir does not exist
ControlInterface->>Logger: qCInfo appLog "Udev rules directory does not exist, creating" rulesDir.absolutePath
ControlInterface->>QDir: rulesDir.mkpath(".")
QDir-->>ControlInterface: success
alt mkpath failed
ControlInterface->>Logger: qCWarning appLog "Failed to create udev rules directory" rulesDir.absolutePath
ControlInterface-->>ControlInterface: return false
else mkpath succeeded
ControlInterface->>Logger: qCInfo appLog "Successfully created udev rules directory" rulesDir.absolutePath
ControlInterface-->>ControlInterface: continue to open rulesFile
end
else rulesDir exists
ControlInterface-->>ControlInterface: continue to open rulesFile
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review我来对这段代码的修改进行审查:
改进建议代码示例: bool ControlInterface::ensureDirectoryExists(const QString& dirPath) {
QDir dir(dirPath);
if (dir.exists()) {
return true;
}
// 检查权限
QFileInfo parentDir(dir.absolutePath());
if (!parentDir.isWritable()) {
qCWarning(appLog) << "No permission to create directory:" << dir.absolutePath();
return false;
}
qCInfo(appLog) << "Creating directory:" << dir.absolutePath();
if (!dir.mkpath(".")) {
qCWarning(appLog) << "Failed to create directory:" << dir.absolutePath();
return false;
}
// 验证目录创建成功且可写
if (!dir.exists() || !dir.isReadable()) {
qCWarning(appLog) << "Directory created but not accessible:" << dir.absolutePath();
return false;
}
qCInfo(appLog) << "Successfully created directory:" << dir.absolutePath();
return true;
}
bool ControlInterface::enableKeyboard(const QString& vid, const QString& pid, const QString& serial) {
// ... 其他代码 ...
QFileInfo fileInfo(rulesFile);
if (!ensureDirectoryExists(fileInfo.absolutePath())) {
return false;
}
QFile file(rulesFile);
// ... 继续处理 ...
}这样的改进:
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- When creating the udev rules directory, consider calling
rulesDir.mkpath(rulesDir.absolutePath())instead ofmkpath(".")to make the intent explicit and avoid relying on relative path semantics forQDir.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- When creating the udev rules directory, consider calling `rulesDir.mkpath(rulesDir.absolutePath())` instead of `mkpath(".")` to make the intent explicit and avoid relying on relative path semantics for `QDir`.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
lzwind
approved these changes
Dec 31, 2025
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos, lzwind 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 |
Contributor
Author
|
/merge |
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.
…enable
create udev rules directory when missing during keyboard enable or disable
log: create udev rules directory
bug: https://pms.uniontech.com/bug-view-346127.html
Summary by Sourcery
Bug Fixes: