Skip to content

Commit d11bb33

Browse files
committed
appstream: drop dead client-timeout plumbing
The http.Client parameter on Update was always passed nil from main; the fallback client timeouts (15m / 2m) were pure dead code since the ctx deadline (10m in runCommand) always wins. Match the convention of the other update commands: no client param, no hand-rolled timeouts. Also unexport latestRelease — it's not called from outside the package.
1 parent 10d30ed commit d11bb33

2 files changed

Lines changed: 6 additions & 17 deletions

File tree

internal/appstream/update.go

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,22 @@ import (
1111
"log/slog"
1212
"net/http"
1313
"strings"
14-
"time"
1514
)
1615

1716
// archlinuxPackageJSON is the official package metadata used to resolve the
1817
// appstream-data snapshot directory name (pkgver). The XML base URL is passed
1918
// into Update as sourcesBase (from config.APPSTREAM_SOURCES_BASE / CLI).
2019
const archlinuxPackageJSON = "https://archlinux.org/packages/extra/any/archlinux-appstream-data/json/"
2120

22-
const (
23-
httpClientTimeoutRelease = 2 * time.Minute
24-
httpClientTimeoutUpdate = 15 * time.Minute
25-
)
26-
2721
var componentRepos = []string{"core", "extra", "multilib"}
2822

2923
type pkgJSON struct {
3024
Pkgver string `json:"pkgver"`
3125
}
3226

33-
// LatestRelease returns the snapshot directory name (e.g. "20260326") matching
27+
// latestRelease returns the snapshot directory name (e.g. "20260326") matching
3428
// the current extra/any archlinux-appstream-data package in the official repos.
35-
func LatestRelease(ctx context.Context, client *http.Client) (string, error) {
36-
if client == nil {
37-
client = &http.Client{Timeout: httpClientTimeoutRelease}
38-
}
29+
func latestRelease(ctx context.Context, client *http.Client) (string, error) {
3930
req, err := http.NewRequestWithContext(ctx, http.MethodGet, archlinuxPackageJSON, nil)
4031
if err != nil {
4132
return "", err
@@ -63,13 +54,11 @@ func LatestRelease(ctx context.Context, client *http.Client) (string, error) {
6354
// Update downloads AppStream component XML for core, extra, and multilib from
6455
// sourcesBase (see config.go), merges keywords and categories
6556
// by package name, writes both columns, and rebuilds the FTS index.
66-
func Update(ctx context.Context, db *sql.DB, client *http.Client, sourcesBase string) error {
67-
if client == nil {
68-
client = &http.Client{Timeout: httpClientTimeoutUpdate}
69-
}
57+
func Update(ctx context.Context, db *sql.DB, sourcesBase string) error {
58+
client := &http.Client{}
7059
sourcesBase = strings.TrimSuffix(sourcesBase, "/") + "/"
7160

72-
version, err := LatestRelease(ctx, client)
61+
version, err := latestRelease(ctx, client)
7362
if err != nil {
7463
return err
7564
}

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func runCommand(cmd string, cfg config.Config) int {
8787
return 1
8888
}
8989
case "update-appstream":
90-
if err := appstream.Update(ctx, db, nil, cfg.AppStreamSourcesBase); err != nil {
90+
if err := appstream.Update(ctx, db, cfg.AppStreamSourcesBase); err != nil {
9191
slog.Error("update-appstream failed", "error", err)
9292
return 1
9393
}

0 commit comments

Comments
 (0)