Skip to content
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

Merged
merged 6 commits into from
Apr 9, 2024

Conversation

yao-msft
Copy link
Contributor

@yao-msft yao-msft commented Apr 6, 2024

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

@yao-msft yao-msft requested a review from a team as a code owner April 6, 2024 00:44
[&]()
{
AppInstallManager installManager;
installManager.Cancel(m_productId);
Copy link
Member

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.

JohnMcPMS
JohnMcPMS previously approved these changes Apr 8, 2024

for (auto const& installItem : installItems)
{
if (Utility::CaseInsensitiveEquals(Utility::ConvertToUTF8(installItem.ProductId()), productId))
Copy link
Member

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Sleep(500);
Sleep(200);

And the appropriate loop count to get back to 10 seconds.

}
}

return HRESULT_FROM_WIN32(ERROR_TIMEOUT);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return HRESULT_FROM_WIN32(ERROR_TIMEOUT);
RETURN_HR(HRESULT_FROM_WIN32(ERROR_TIMEOUT));

Comment on lines 239 to 242
if (FAILED(restartOrCancelResult))
{
// Wait a bit
Sleep(500);
return restartOrCancelResult;
}
Copy link
Member

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.

@yao-msft
Copy link
Contributor Author

yao-msft commented Apr 8, 2024

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@yao-msft
Copy link
Contributor Author

yao-msft commented Apr 9, 2024

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@yao-msft yao-msft merged commit 91ee267 into microsoft:master Apr 9, 2024
8 checks passed
@yao-msft yao-msft deleted the improvemsstoreinstall branch April 9, 2024 17:34
yao-msft added a commit to yao-msft/winget-cli that referenced this pull request Apr 9, 2024
… 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)
yao-msft added a commit that referenced this pull request Apr 9, 2024
… 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants