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

Add support for extracting archives using tar.exe #4541

Merged
merged 8 commits into from
Jun 18, 2024

Conversation

ryfu-msft
Copy link
Contributor

@ryfu-msft ryfu-msft commented Jun 5, 2024

We have received feedback noting that the shell api fails to extract archives in certain scenarios. This adds an alternative way of extracting archives by invoking the tar.exe executable which is included in version later than 17063.

  • Added install behavior setting extractArchiveWithTar that takes in a boolean value. If no value is specified or value is not valid, the default extract behavior will utilize the Windows Shell API.
  • Added tests to verify that the archive extraction behavior still works.
Microsoft Reviewers: Open in CodeFlow

@ryfu-msft ryfu-msft requested a review from a team as a code owner June 5, 2024 18:53
auto tarExecPath = AppInstaller::Filesystem::GetExpandedPath("%windir%\\system32\\tar.exe");

std::string args = "-xf " + m_archivePath.u8string() + " -C " + m_destPath.u8string();
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you try paths with spaces (i.e. do we need to quote the path)?

tar.exe -xf c:\t e s t.zip -C C:\d e s t

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added single quotes to avoid issues with space in path

doc/Settings.md Outdated

```json
"installBehavior": {
"extractArchiveWithTar": true
Copy link
Contributor

Choose a reason for hiding this comment

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

I was expecting a string setting like below for extensibility

"archiveExtraction": "tar" allowed values are (tar, shellApi)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed to archiveExtractionMethod that takes in string values.

@ryfu-msft
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@@ -514,6 +514,24 @@ TEST_CASE("ExtractInstallerFromArchive_InvalidZip", "[InstallFlow][workflow]")
REQUIRE(installOutput.str().find(Resource::LocString(Resource::String::ExtractArchiveFailed).get()) != std::string::npos);
}

TEST_CASE("ExtractInstallerFromArchiveWithTar_InvalidZip", "[InstallFlow][workflow]")
Copy link
Member

Choose a reason for hiding this comment

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

Please have a success case in the unit tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a success case unit test that uses a test hook to override the result of invoking tar.exe so that it returns success and verifies that the install flow can run successfully with the correct string output.

return Archive::ExtractionMethod::ShellApi;
}

return {};
Copy link
Contributor

Choose a reason for hiding this comment

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

what is "return {}" for enum return values? I guess we could add Archive::ExtractionMethod::Unknown and return the unknown enum

@ryfu-msft ryfu-msft merged commit a9d6548 into microsoft:master Jun 18, 2024
8 checks passed
@ryfu-msft ryfu-msft deleted the zipTar branch June 18, 2024 21:16
ryfu-msft added a commit to ryfu-msft/winget-cli that referenced this pull request Jun 20, 2024
ryfu-msft added a commit to ryfu-msft/winget-cli that referenced this pull request Jun 25, 2024
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.

None yet

3 participants