Import-SamyChunk 2

This commit is contained in:
2026-01-31 21:42:42 -05:00
parent b6c796dd06
commit a8b058e21e

View File

@@ -61,36 +61,28 @@ function Import-SamyChunk {
[CmdletBinding()] [CmdletBinding()]
param( param(
[Parameter(Mandatory)][string]$Url, [Parameter(Mandatory)][string]$Url,
[Parameter(Mandatory)][string]$Name, [Parameter(Mandatory)][string]$Name
[Parameter(Mandatory)][string]$LocalPath
) )
try { try {
# Download
$content = (Invoke-WebRequest -UseBasicParsing -Uri $Url -ErrorAction Stop).Content $content = (Invoke-WebRequest -UseBasicParsing -Uri $Url -ErrorAction Stop).Content
if ([string]::IsNullOrWhiteSpace($content)) { if ([string]::IsNullOrWhiteSpace($content)) {
throw "Downloaded content was empty." throw "Downloaded content was empty."
} }
# 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 Write-Host ("[Success] {0}" -f $Name) -ForegroundColor Green
return $true return $content
} }
catch { catch {
$msg = $_.Exception.Message $msg = $_.Exception.Message
if ([string]::IsNullOrWhiteSpace($msg)) { $msg = "$_" } if ([string]::IsNullOrWhiteSpace($msg)) { $msg = "$_" }
Write-Host ("[Failed] {0}: {1}" -f $Name, $msg) -ForegroundColor Red Write-Host ("[Failed] {0}: {1}" -f $Name, $msg) -ForegroundColor Red
return $false throw
} }
} }
# Single source of truth for where chunks live # Single source of truth for where chunks live
# (Matches your current inline values) # (Matches your current inline values)
$Script:SamyGitURL = 'https://git.svstools.ca/SVS_Public_Repo/SAMY/raw/branch' $Script:SamyGitURL = 'https://git.svstools.ca/SVS_Public_Repo/SAMY/raw/branch'