-
Notifications
You must be signed in to change notification settings - Fork 47
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
Selection of default upgrade policy #239
Conversation
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.
clang-tidy
in the new code
clang-format
found formatting issues in the code submitted.:warning:
Make sure to run clang-format and update this pull request.
(1/1)
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.
clang-tidy
in the new code
clang-format
found formatting issues in the code submitted.:warning:
Make sure to run clang-format and update this pull request.
(1/1)
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.
clang-tidy
in the new code
clang-format
found formatting issues in the code submitted.:warning:
Make sure to run clang-format and update this pull request.
(1/1)
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.
We are almost done, I think.
DistroLauncher/upgrade_policy.cpp
Outdated
const fs::path log{L"/var/log/upgrade-policy-changed.log"}; | ||
const fs::path policyfile{L"/etc/update-manager/release-upgrades"}; | ||
|
||
if (fs::exists(Oobe::WindowsPath(log))) { |
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.
Since this line will run on every launch, it is subject to user configuration preventing Windows from being able to execute the filesystem calls, thus throwing filesystem exceptions. You may want to consider calling the std::error_code
overload to avoid such behavior.
Now we raise a subsequent question; what to do on error? If we cannot assess whether the log exists or not through the filesystem API what should we do? We can fallback to test with a Linux command, like if (WslLaunchSuccess(L"ls $log"))
.
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.
Agree on the fallback mechanism. I used test -f $log
.
void SetDefaultUpgradePolicy() | ||
{ | ||
auto mutex = NamedMutex(L"upgrade-policy"); | ||
mutex.lock().and_then(internal::SetDefaultUpgradePolicyImpl); |
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.
An alternative to my previous comment about filesystem exceptions might be setting a reasonable or_else
function here. But that seems more complicated, unless you don't want to proceed in case of filesystem errors.
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.
Beware that or_else
is called when we fail to switch user to root.
Throwing an exception during and_then
will only revert the user to default and rethrow again; it will not call or_else
.
I think the best is to have a fallback.
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.
clang-tidy
in the new code
clang-format
found formatting issues in the code submitted.:warning:
Make sure to run clang-format and update this pull request.
(1/1)
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.
LGTM!
Please do not forget to squash that one. There are a lot of less-interesting commits due merges and linting fixes overloading the commit history.
I merged, because I'll need one function you've implemented here. |
This PR is a temporary solution to #226.