-
Notifications
You must be signed in to change notification settings - Fork 43
fix: convert file:// to local path #264
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
Reviewer's Guide by SourceryThis pull request modifies how the application service handles file paths and URLs passed to applications launched via desktop entries. It converts Sequence diagram for launching application with local file path conversionsequenceDiagram
participant ApplicationService
participant LaunchTask
participant QUrl
ApplicationService->>LaunchTask: unescapeExec(str, fields)
activate LaunchTask
LaunchTask->>LaunchTask: Process %F or %f
LaunchTask->>QUrl: QUrl::fromUserInput(str)
activate QUrl
QUrl-->>LaunchTask: url
deactivate QUrl
LaunchTask->>LaunchTask: url.isLocalFile()
alt isLocalFile() == true
LaunchTask->>LaunchTask: str = url.toLocalFile()
end
LaunchTask-->>ApplicationService: task
deactivate LaunchTask
ApplicationService->>ApplicationService: Launch(action, fields, task)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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 @ComixHe - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider adding some comments to explain the logic within the
std::for_eachlambda inApplicationService::Launch. - It might be helpful to introduce some more descriptive variable names to improve readability.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| }); | ||
| } | ||
|
|
||
| auto newCmds = task.command; |
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.
issue (complexity): Consider replacing lambdas and reverse-iterator insertions with explicit loops to improve readability and maintainability of the code.
Consider replacing these lambdas and reverse-iterator insertions with explicit, simple loops. For example, instead of this:
std::for_each(
rawRes.rbegin(), rawRes.rend(),
[&newCmds, &it](QString &str) { it = newCmds.insert(it, str); }
);
you could simplify it to a clear reverse loop:
if (task.fieldLocation == -1) {
for (int i = rawRes.size() - 1; i >= 0; --i) {
newCmds.insert(task.argNum + 1, rawRes.at(i));
}
} else {
auto arg = newCmds.begin() + task.argNum + 1;
arg->insert(task.fieldLocation, rawRes.takeFirst());
++arg;
for (int i = rawRes.size() - 1; i >= 0; --i) {
newCmds.insert(arg, rawRes.at(i));
}
}
Similarly, for URL processing, replace the lambda with a range-based loop:
if (task.local) {
for (auto &str : rawRes) {
QUrl url = QUrl::fromUserInput(str);
if (url.isLocalFile()) {
str = url.toLocalFile();
}
// Optionally handle remote files in a separate function.
}
}
These changes preserve functionality while reducing layered abstractions and nested lambdas, improving readability and maintainability.|
TAG Bot TAG: 1.2.27 |
passing local path to application instead of url when desktop Exec specify %F or %f. other change: - respect the original url, passing it to application directly - correct the application command generating process Signed-off-by: ComixHe <heyuming@deepin.org>
Signed-off-by: ComixHe <heyuming@deepin.org>
deepin pr auto review代码审查意见:
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: BLumia, ComixHe 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 |
|
/integrate |
|
AutoIntegrationPr Bot |
passing local path to application instead of url when desktop Exec specify %F or %f.
other change:
Summary by Sourcery
Improve handling of file URLs and local paths when launching applications through desktop entry files
Bug Fixes:
Enhancements: