return json even if no packages are queued; fix 404

This commit is contained in:
2025-03-23 22:57:15 +01:00
parent 8be1c59065
commit 817b3b32b1

14
main.go
View File

@@ -86,6 +86,14 @@ func main() {
if *exitCodeFlag { if *exitCodeFlag {
os.Exit(20) os.Exit(20)
} }
} else {
log.Debugf("no packages in queue")
if *jsonFlag {
err = json.NewEncoder(os.Stdout).Encode(JSONOut{
Total: len(packagesInQueue),
Packages: packagesInQueue,
})
}
} }
} }
@@ -127,10 +135,10 @@ func ALHPBuildQueuePkgbase() ([]string, error) {
} }
defer resp.Body.Close() defer resp.Body.Close()
if resp.StatusCode != http.StatusOK { if resp.StatusCode == http.StatusNotFound {
return nil, fmt.Errorf("ALHP api returned HTTP %d", resp.StatusCode)
} else if resp.StatusCode == http.StatusNotFound {
return nil, nil return nil, nil
} else if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("ALHP api returned HTTP %d", resp.StatusCode)
} }
bResp, err := io.ReadAll(resp.Body) bResp, err := io.ReadAll(resp.Body)