From bbfa1ba0b77cdf59469f164c5bcfe09dc83a688e Mon Sep 17 00:00:00 2001 From: stummsft <36856682+stummsft@users.noreply.github.com> Date: Thu, 22 Aug 2019 13:33:53 -0700 Subject: [PATCH] Fix: Partial fix to issue #40 This only addresses the partial root cause where a provided file is inaccessible among a set of otherwise successful files. --- .../Microsoft.PowerShell.Archive.psm1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Microsoft.PowerShell.Archive/Microsoft.PowerShell.Archive.psm1 b/Microsoft.PowerShell.Archive/Microsoft.PowerShell.Archive.psm1 index 2ed4c84..beff22a 100644 --- a/Microsoft.PowerShell.Archive/Microsoft.PowerShell.Archive.psm1 +++ b/Microsoft.PowerShell.Archive/Microsoft.PowerShell.Archive.psm1 @@ -818,6 +818,10 @@ function ZipArchiveHelper } $errorRecord = CreateErrorRecordHelper "CompressArchiveUnauthorizedAccessError" $null ([System.Management.Automation.ErrorCategory]::PermissionDenied) $exception $currentFilePath Write-Error -ErrorRecord $errorRecord + + # Set $currentFileStream to null to prevent incorrectly entering the next + # block if this is not the first file + $currentFileStream = $null; } if($null -ne $currentFileStream)