Skip to content

Commit

Permalink
Update IoHelpers.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Oct 11, 2023
1 parent c4c2f9b commit 9b67d3a
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/Verify/IoHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,18 @@ public static async Task<StringBuilder> ReadStringBuilderWithFixedLines(string p
public static async Task WriteStream(string path, Stream stream)
{
CreateDirectory(Path.GetDirectoryName(path));
if (!TryCopyFileStream(path, stream))
if (TryCopyFileStream(path, stream))
{
// keep using scope to stream is flushed
using (var targetStream = OpenWrite(path))
{
await stream.SafeCopy(targetStream);
}
return;
}

HandleEmptyFile(path);
// keep using scope to stream is flushed
using (var targetStream = OpenWrite(path))
{
await stream.SafeCopy(targetStream);
}

HandleEmptyFile(path);
}

#endif
Expand Down

0 comments on commit 9b67d3a

Please sign in to comment.