Skip to content

Commit b32da21

Browse files
committed
Fixed performance problem with Set-Content using values from pipeline
Replaced Set-Content call with native .NET method API call
1 parent 8ad93e9 commit b32da21

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Slack.Backup/Private/backup/Invoke-FilesBackup.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ function Invoke-FilesBackup {
2323
$start = Convert-DateToEpoch (Get-Date "2000-01-01")
2424
}
2525

26-
$files = Get-FilesList -Token $key -TsFrom $start
26+
$files = Get-FilesList -Token $Token -TsFrom $start
2727
if ($files.ok) {
2828
foreach ($f in $files | Select-Object -ExpandProperty files) {
2929
$ext = $f.filetype
3030
$path = "$backupLoc/$($f.id)"
31-
Get-SlackFile -Token $key -Uri $f.url_private | Set-Content "$path.$ext" -AsByteStream
31+
$slackFile = Get-SlackFile -Token $Token -Uri $f.url_private
32+
[System.IO.File]::WriteAllBytes("$path.$ext", $slackFile)
3233
$f | ConvertTo-Json -Depth 10 | Set-Content -Path "$path.json"
3334
}
3435
}

0 commit comments

Comments
 (0)