Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#1332) Add switch to disable logging for archive extraction #2449

Merged
merged 1 commit into from
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/chocolatey.resources/helpers/functions/Get-ChocolateyUnzip.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ folder and its contents will be extracted to the destination.
OPTIONAL - This will facilitate logging unzip activity for subsequent
uninstalls

.PARAMETER DisableLogging
OPTIONAL - This disables logging of the extracted items. It speeds up
extraction of archives with many files.

Usage of this parameter will prevent Uninstall-ChocolateyZipPackage
from working, extracted files will have to be cleaned up with
Remove-Item or a similar command instead.

.PARAMETER IgnoredArguments
Allows splatting with arguments that do not apply. Do not use directly.

Expand All @@ -93,6 +101,7 @@ param(
[parameter(Mandatory=$false, Position=2)][string] $specificFolder,
[parameter(Mandatory=$false, Position=3)][string] $packageName,
[alias("file64")][parameter(Mandatory=$false)][string] $fileFullPath64,
[parameter(Mandatory=$false)][switch] $disableLogging,
[parameter(ValueFromRemainingArguments = $true)][Object[]] $ignoredArguments
)

Expand Down Expand Up @@ -156,7 +165,12 @@ param(
}
$workingDirectory = $workingDirectory.ProviderPath

$params = "x -aoa -bd -bb1 -o`"$destinationNoRedirection`" -y `"$fileFullPathNoRedirection`""
$loggingParam = '-bb1'
if ($disableLogging) {
$loggingParam = '-bb0'
}

$params = "x -aoa -bd $loggingParam -o`"$destinationNoRedirection`" -y `"$fileFullPathNoRedirection`""
if ($specificfolder) {
$params += " `"$specificfolder`""
}
Expand Down Expand Up @@ -219,7 +233,7 @@ param(
Set-PowerShellExitCode $exitCode
Write-Debug "Command ['$7zip' $params] exited with `'$exitCode`'."

if ($zipExtractLogFullPath) {
if ($zipExtractLogFullPath -and -not $disableLogging) {
Set-Content $zipExtractLogFullPath $global:zipFileList.ToString() -Encoding UTF8 -Force
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ Will be used for Url64bit if Url64bit is empty. Available in 0.10.7+.
This parameter provides compatibility, but should not be used directly
and not with the community package repository until January 2018.

.PARAMETER DisableLogging
OPTIONAL - This disables logging of the extracted items. It speeds up
extraction of archives with many files.

Usage of this parameter will prevent Uninstall-ChocolateyZipPackage
from working, extracted files will have to be cleaned up with
Remove-Item or a similar command instead.

.PARAMETER IgnoredArguments
Allows splatting with arguments that do not apply. Do not use directly.

Expand Down Expand Up @@ -191,6 +199,7 @@ param(
[parameter(Mandatory=$false)][hashtable] $options = @{Headers=@{}},
[alias("fileFullPath")][parameter(Mandatory=$false)][string] $file = '',
[alias("fileFullPath64")][parameter(Mandatory=$false)][string] $file64 = '',
[parameter(Mandatory=$false)][switch] $disableLogging,
[parameter(ValueFromRemainingArguments = $true)][Object[]] $ignoredArguments
)

Expand All @@ -213,5 +222,5 @@ param(
}

$filePath = Get-ChocolateyWebFile $packageName $downloadFilePath $url $url64bit -checkSum $checkSum -checksumType $checksumType -checkSum64 $checkSum64 -checksumType64 $checksumType64 -options $options -getOriginalFileName
Get-ChocolateyUnzip "$filePath" $unzipLocation $specificFolder $packageName
Get-ChocolateyUnzip "$filePath" $unzipLocation $specificFolder $packageName -disableLogging:$disableLogging
}