internal/pkg: return reader for files
All checks were successful
Test / Create distribution (push) Successful in 47s
Test / Sandbox (push) Successful in 2m51s
Test / ShareFS (push) Successful in 4m41s
Test / Sandbox (race detector) (push) Successful in 5m17s
Test / Hpkg (push) Successful in 5m31s
Test / Hakurei (race detector) (push) Successful in 7m28s
Test / Hakurei (push) Successful in 3m48s
Test / Flake checks (push) Successful in 1m42s

This improves efficiency for cache hits.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-01-07 21:36:47 +09:00
parent 7ea4e8b643
commit e8dda70c41
3 changed files with 28 additions and 21 deletions

View File

@@ -8,6 +8,7 @@ import (
"encoding/binary"
"errors"
"fmt"
"io"
"io/fs"
"net/http"
"os"
@@ -536,10 +537,14 @@ func TestCache(t *testing.T) {
fs.ModeDir | 0500,
)},
{"loadData directory", overrideIdent{pkg.ID{0xff, 3}, stubArtifact{
{"openFile directory", overrideIdent{pkg.ID{0xff, 3}, stubArtifact{
kind: pkg.KindTar,
cure: func(c *pkg.CureContext) error {
_, err := c.LoadData(overrideChecksumFile{checksum: wantChecksum})
r, err := c.OpenFile(overrideChecksumFile{checksum: wantChecksum})
if err != nil {
panic(err)
}
_, err = io.ReadAll(r)
return err
},
}}, nil, pkg.Checksum{}, &os.PathError{