Skip to content

Commit

Permalink
fix: Use 'checkurls.ps1` to check downloading (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
niheaven committed Mar 20, 2024
1 parent 9fa5cad commit ec444d3
Showing 1 changed file with 19 additions and 31 deletions.
50 changes: 19 additions & 31 deletions src/Action/Issue.psm1
Expand Up @@ -10,7 +10,7 @@ function Test-Hash {
$gci, $man = Get-Manifest $Manifest
$manifestNameAsInBucket = $gci.BaseName

$outputH = @(& (Join-Path $BINARIES_FOLDER 'checkhashes.ps1') -App $gci.Basename -Dir $MANIFESTS_LOCATION -Force *>&1)
$outputH = @(& (Join-Path $BINARIES_FOLDER 'checkhashes.ps1') -App $manifestNameAsInBucket -Dir $MANIFESTS_LOCATION -Force *>&1)
Write-Log 'Output' $outputH

if (($outputH[-2] -like 'OK') -and ($outputH[-1] -like 'Writing*')) {
Expand Down Expand Up @@ -102,36 +102,21 @@ function Test-Hash {
}

function Test-Downloading {
param([String] $Manifest, [Int] $IssueID)

$null, $object = Get-Manifest $Manifest

$broken_urls = @()
# TODO:? Aria2 support
# Invoke-CachedAria2Download $Manifest 'DL' $object (default_architecture) "/" $object.cookies $true

# exit 0
foreach ($arch in @('64bit', '32bit', 'arm64')) {
$urls = @(url $object $arch)
param (
[Parameter(Mandatory = $true)]
[String] $Manifest,
[Int] $IssueID
)

foreach ($url in $urls) {
# Trim rename (#48)
$url = $url -replace '#/.*$', ''
Write-Log 'url' $url
$gci, $man = Get-Manifest $Manifest

try {
Invoke-CachedDownload $Manifest 'DL' $url $null $object.cookies $true
} catch {
$broken_urls += $url
continue
}
}
}
$outputH = @(& (Join-Path $BINARIES_FOLDER 'checkurls.ps1') -App $gci.BaseName -Dir $MANIFESTS_LOCATION *>&1)
$broken_urls = $outputH -match '>' -replace '.*?>', '-'

if ($broken_urls.Count -eq 0) {
Write-Log 'All OK'
if (!$broken_urls) {
Write-Log 'Cannot reproduce'

$message = @(
Add-Comment -ID $IssueID -Message @(
'Cannot reproduce.'
''
'All files could be downloaded without any issue.'
Expand All @@ -144,14 +129,17 @@ function Test-Downloading {
'- Aria2 being unreliable (if you''re facing problems with aria2, disable it by running `scoop config aria2-enabled false` and try again)'
)

Add-Comment -ID $IssueID -Comment $message
Remove-Label -ID $IssueID -Label 'manifest-fix-needed'
Close-Issue -ID $IssueID
} else {
Write-Log 'Broken URLS' $broken_urls
Write-Log 'Broken URLs' $broken_urls

$string = ($broken_urls | Select-Object -Unique | ForEach-Object { "- $_" }) -join "`r`n"
Add-Comment -ID $IssueID -Message @(
'You are right. Thank you for reporting.',
'',
'Following URLs are not accessible:'
) + $broken_urls
Add-Label -ID $IssueID -Label 'manifest-fix-needed', 'verified', 'help wanted'
Add-Comment -ID $IssueID -Comment 'Thank you for reporting. You are right.', '', 'Following URLs are not accessible:', '', $string
}
}

Expand Down

0 comments on commit ec444d3

Please sign in to comment.