💾 Archived View for g.mikf.pl › fragmlog › 2023-04-01-powershell--files › changes.ps1.diff captured on 2024-05-12 at 15:12:54. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-07-22)
-=-=-=-=-=-=-
[1mdiff --git a/./before_changes.ps1 b/./after_changes.ps1[m
[1mindex 7f7f27a..42dfb08 100644[m
[1m--- a/./before_changes.ps1[m
[1m+++ b/./after_changes.ps1[m
[36m@@ -1,4 +1,11 @@[m
[32m+[m[32mparam ([m
[32m+[m[32m [Parameter(Position = 0)][m
[32m+[m[32m [ScriptBlock]$ScriptBlock = { }[m
[32m+[m[32m)[m
[32m+[m
[32m+[m[32m$TheContentJob = & { $TempFile = New-TemporaryFile[m
[32m+[m[32mWrite-Information "Temporary file name '$TempFile'. " -InformationAction Continue[m
[31m-Import-Module `[m
[32m+[m[32m& { Import-Module `[m
"C:\Users\Mika Feiler\$([m
)\source\repos\DotnetTarGzipper\$([m
)\bin\Release\net7.0\DotnetTarGzipper.dll"[m
[36m@@ -12,10 +19,6 @@[m [mSet-Location $GemCap[m
+"# Mika Feiler%n=> tinylog.gmi %F Tinylog" > gemfeed-tinylog.gmi'[m
Pop-Location[m
[m
[31m-$TempFile = New-TemporaryFile[m
[31m-Write-Host "Temporary file name '$TempFile'. "[m
[31m-$SrHtTokenKey = "SrHtToken_g.mikf.pl"[m
[31m-[m
Get-ChildItem $GemCap -File -Recurse -Name |[m
Where-Object { $_ -NotMatch "^(.*[\\\/])?\..*" } |[m
ForEach-Object { $_ -replace '\\', '/' } |[m
[36m@@ -23,9 +26,15 @@[m [mNew-Tar (Resolve-Path $GemCap) |[m
Compress-Gzip |[m
Set-Content -Path $TempFile -AsByteStream[m
[m
[31m-Write-Host "Finished creating archive. "[m
[32m+[m[32mWrite-Information "Finished creating archive. " -InformationAction Continue[m
[32m+[m[32m} 1>$null[m
[32m+[m[32mreturn $TempFile[m
[32m+[m[32m} &[m
[32m+[m
[32m+[m[32m& ScriptBlock &[m
[m
function Get-SrHtToken {[m
[32m+[m[32m $SrHtTokenKey = "SrHtToken_g.mikf.pl"[m
$SrHtToken = Get-Secret $SrHtTokenKey -ErrorVariable NoSrhtToken[m
if($NoSrhtToken.Exception -Is `[m
[System.Management.Automation.ItemNotFoundException]) {[m
[36m@@ -34,12 +43,16 @@[m [mfunction Get-SrHtToken {[m
}[m
$SrHtToken[m
}[m
[32m+[m[32m$TempFile = Get-ChildItem -Path (Wait-Job $TheContentJob | Receive-Job)[m
Invoke-WebRequest -Method Post `[m
-Uri "https://pages.sr.ht/publish/g.mikf.pl" `[m
-Authentication OAuth -Token (Get-SrHtToken) `[m
-Form @{[m
protocol = "GEMINI"[m
[31m- content = Get-ChildItem $TempFile[m
[32m+[m[32m content = $TempFile[m
} `[m
-RetryIntervalSec 2 -MaximumRetryCount 3 |[m
ForEach-Object { Write-Host $_.RawContent }[m
[32m+[m[32mRemove-Job $TheContentJob[m
[32m+[m[32mWrite-Information -InformationAction Continue "Actual:"[m
[32m+[m[32mGet-FileHash -Algorithm SHA256 $TempFile | foreach-object { Write-Host $_.Hash.ToLower() }[m