PowerShell / PSResourceGet

PSResourceGet is the package manager for PowerShell
https://www.powershellgallery.com/packages/Microsoft.PowerShell.PSResourceGet
MIT License
494 stars 93 forks source link

Fix 1659 "Some Nuget packages fail to extract" #1707

Closed o-l-a-v closed 1 month ago

o-l-a-v commented 2 months ago

PR Summary

Fixes #1659.

I noticed that the example problematic package Microsoft.Web.WebView2 ( https://www.nuget.org/packages/Microsoft.Web.WebView2 ) mentioned by the creator of the issue, contained directories when doing ZipFile.OpenRead and looking at the entries. Non-problematic packages, like NuGet.Versioning ( https://www.nuget.org/packages/NuGet.Versioning ) did not.

image

Solution: Filter out entries where length is less than or equal to 0 (because they are not files).

PR Context

See previous chapter.

PR Checklist

o-l-a-v commented 2 months ago

We should probably add a test to make sure this does not happen again? But you probably want another "test_modulex" rather testing by fetching Microsoft.Web.WebView2 ( https://www.nuget.org/packages/Microsoft.Web.WebView2 )?

Must be a .nupkg where ZipFile.OpenRead will have entries where CompressedLength is less than 1, a.k.a a directory.

alerickson commented 1 month ago

So funny enough, when I tried to create a similarly structured .nupkg I wasn't able to repro the issue-- the only entries displayed were files and not directories. image

I added a version of Microsoft.Web.WebView2 that is definitely reproducing the error and added a test to the local repository test file to validate it can install properly.

Thanks for fixing this bug!