Skip to content

Commit

Permalink
(chocolatey#2076) Pack always truncate stream
Browse files Browse the repository at this point in the history
Mono does not truncate streams in System.IO.Packaging.Package.Open
when using FileMode.Create, while .Net does. mono/mono#21055

This always truncates the stream at the start.
  • Loading branch information
TheCakeIsNaOH authored and gep13 committed Sep 19, 2021
1 parent ac806ee commit f5fc7ba
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/chocolatey/infrastructure.app/nuget/NugetPack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public static IPackage BuildPackage(PackageBuilder builder, IFileSystem fileSyst
{
using (Stream stream = fileSystem.create_file(outputPath))
{
// Truncate if needed, as Mono fails to truncate
if (stream.Length > 0)
{
stream.SetLength(0);
}
builder.Save(stream);
}
}
Expand Down

0 comments on commit f5fc7ba

Please sign in to comment.