-
Notifications
You must be signed in to change notification settings - Fork 40
fix(input): create udev rules directory when missing during keyboard … #591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
|
[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 |
|
/merge |
…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: