-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Improve MSStore installation success rate by trying Restart or Cancel when applicable #4356
Conversation
[&]() | ||
{ | ||
AppInstallManager installManager; | ||
installManager.Cancel(m_productId); |
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 probably want to try/catch this whole lambda to prevent any errors from potentially terminating the process.
|
||
for (auto const& installItem : installItems) | ||
{ | ||
if (Utility::CaseInsensitiveEquals(Utility::ConvertToUTF8(installItem.ProductId()), productId)) |
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.
This seems like a lot of string conversions to avoid having a CaseInsensitiveEquals(wstring_view, wstring_view)
.
// Wait for at most 10 seconds for install item to be removed from queue. | ||
for (int i = 0; i < 20; ++i) | ||
{ | ||
Sleep(500); |
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.
Sleep(500); | |
Sleep(200); |
And the appropriate loop count to get back to 10 seconds.
} | ||
} | ||
|
||
return HRESULT_FROM_WIN32(ERROR_TIMEOUT); |
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.
return HRESULT_FROM_WIN32(ERROR_TIMEOUT); | |
RETURN_HR(HRESULT_FROM_WIN32(ERROR_TIMEOUT)); |
if (FAILED(restartOrCancelResult)) | ||
{ | ||
// Wait a bit | ||
Sleep(500); | ||
return restartOrCancelResult; | ||
} |
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.
Get rid of this and just us RETURN_IF_FAILED
on the call to RestartOrCancelExistingOperationIfNecessary
.
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
… when applicable (microsoft#4356) After calling to InstallProductAsync, try to check status of existing install items and call Restart or Cancel if applicable. After our operation failed, clean up the installation queue by calling cancel. I manually validated by opening Store app, install a test app and pause the installation. Then use winget to install the same app. App installation failed before the change and succeeded after the change. ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/microsoft/winget-cli/pull/4356)
… when applicable (#4356) After calling to InstallProductAsync, try to check status of existing install items and call Restart or Cancel if applicable. After our operation failed, clean up the installation queue by calling cancel. I manually validated by opening Store app, install a test app and pause the installation. Then use winget to install the same app. App installation failed before the change and succeeded after the change. ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/microsoft/winget-cli/pull/4356)
After calling to InstallProductAsync, try to check status of existing install items and call Restart or Cancel if applicable.
After our operation failed, clean up the installation queue by calling cancel.
I manually validated by opening Store app, install a test app and pause the installation. Then use winget to install the same app. App installation failed before the change and succeeded after the change.
Microsoft Reviewers: Open in CodeFlow