chore: update golangci-lint to v2.12.2 with canonical config (#54)
All checks were successful
check / check (push) Successful in 4s

Canonical v2-schema `.golangci.yml`, golangci-lint pins bumped to v2.12.2 in `Dockerfile` and `script/bootstrap`, and the tree brought to `0 issues.` under it.

Three behaviour deltas: `Cache.StoreVariant` takes a context (cancelled requests skip the accounting row, recovered by reconciliation); `MetadataStorage.Store` no longer leaks `.tmp-*.json` on Write/Close/Rename failure (dead-defer bug fix); the `signing_key` too-short error text gained a `value too short:` prefix.

Eviction-loop context cancellation deferred to #102.
This commit was merged in pull request #54.
This commit is contained in:
2026-08-10 16:12:22 +02:00
parent 63fbc98e63
commit 2d805125ee
61 changed files with 3550 additions and 2472 deletions

View File

@@ -4,12 +4,14 @@ import (
"context"
"errors"
"fmt"
"io"
"io/fs"
"net/http"
"strings"
)
// errEmptyURLPath is returned when a mock URL has no usable path.
var errEmptyURLPath = errors.New("empty URL path")
// MockFetcher implements Fetcher using an embedded filesystem.
// Files are organized as: hostname/path/to/file.ext
// URLs like https://example.com/images/photo.jpg map to example.com/images/photo.jpg.
@@ -59,7 +61,7 @@ func (m *MockFetcher) Fetch(ctx context.Context, url string) (*FetchResult, erro
contentType := detectContentTypeFromPath(path)
return &FetchResult{
Content: f.(io.ReadCloser),
Content: f,
ContentLength: stat.Size(),
ContentType: contentType,
Headers: make(http.Header),
@@ -86,7 +88,7 @@ func urlToFSPath(rawURL string) (string, error) {
}
if url == "" {
return "", errors.New("empty URL path")
return "", errEmptyURLPath
}
return url, nil
@@ -98,18 +100,18 @@ func detectContentTypeFromPath(path string) string {
switch {
case strings.HasSuffix(path, ".jpg"), strings.HasSuffix(path, ".jpeg"):
return "image/jpeg"
return contentTypeJPEG
case strings.HasSuffix(path, ".png"):
return "image/png"
return contentTypePNG
case strings.HasSuffix(path, ".gif"):
return "image/gif"
return contentTypeGIF
case strings.HasSuffix(path, ".webp"):
return "image/webp"
return contentTypeWebP
case strings.HasSuffix(path, ".avif"):
return "image/avif"
return contentTypeAVIF
case strings.HasSuffix(path, ".svg"):
return "image/svg+xml"
return contentTypeSVG
default:
return "application/octet-stream"
return contentTypeOctetStream
}
}