change Import-SamyChunk

This commit is contained in:
2026-01-31 21:38:25 -05:00
parent 26c6281f13
commit b6c796dd06

View File

@@ -61,18 +61,33 @@ function Import-SamyChunk {
[CmdletBinding()]
param(
[Parameter(Mandatory)][string]$Url,
[Parameter(Mandatory)][string]$Name
[Parameter(Mandatory)][string]$Name,
[Parameter(Mandatory)][string]$LocalPath
)
Write-Host "[Info] Loading chunk: $Name" -ForegroundColor Cyan
try {
# Download
$content = (Invoke-WebRequest -UseBasicParsing -Uri $Url -ErrorAction Stop).Content
if ([string]::IsNullOrWhiteSpace($content)) {
throw "Downloaded content was empty."
}
Write-Host "[Success] Downloaded: $Name" -ForegroundColor Green
return $content
# Save (UTF-8 no BOM)
$utf8NoBom = New-Object System.Text.UTF8Encoding($false)
[System.IO.File]::WriteAllText($LocalPath, $content, $utf8NoBom)
# Load
. $LocalPath
Write-Host ("[Success] {0}" -f $Name) -ForegroundColor Green
return $true
}
catch {
$msg = $_.Exception.Message
if ([string]::IsNullOrWhiteSpace($msg)) { $msg = "$_" }
Write-Host ("[Failed] {0}: {1}" -f $Name, $msg) -ForegroundColor Red
return $false
}
}