From 9b67d3ae41209040d9cbc181b79ad5b8a9313b0e Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Wed, 11 Oct 2023 13:26:07 +1100 Subject: [PATCH] Update IoHelpers.cs --- src/Verify/IoHelpers.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Verify/IoHelpers.cs b/src/Verify/IoHelpers.cs index 7bb56f7469..9976a08006 100644 --- a/src/Verify/IoHelpers.cs +++ b/src/Verify/IoHelpers.cs @@ -238,16 +238,18 @@ public static async Task 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