internal/pkg: move dependency flooding to cache
All checks were successful
Test / Create distribution (push) Successful in 47s
Test / Sandbox (push) Successful in 2m50s
Test / ShareFS (push) Successful in 4m46s
Test / Sandbox (race detector) (push) Successful in 5m16s
Test / Hpkg (push) Successful in 5m24s
Test / Hakurei (push) Successful in 5m40s
Test / Hakurei (race detector) (push) Successful in 7m27s
Test / Flake checks (push) Successful in 1m42s

This imposes a hard upper limit to concurrency during dependency satisfaction and moves all dependency-related code out of individual implementations of Artifact. This change also includes ctx and msg as part of Cache.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-01-09 01:51:39 +09:00
parent f2430b5f5e
commit f712466714
11 changed files with 680 additions and 409 deletions

View File

@@ -34,9 +34,8 @@ type tarArtifact struct {
}
// NewTar returns a new [Artifact] backed by the supplied [Artifact] and
// compression method. If f implements [File], its data might be used directly,
// eliminating the roundtrip to vfs. If f is a directory, it must contain a
// single regular file.
// compression method. The source [Artifact] must be compatible with
// [TContext.Open].
func NewTar(a Artifact, compression uint64) Artifact {
return &tarArtifact{a, compression}
}
@@ -74,36 +73,11 @@ func (e DisallowedTypeflagError) Error() string {
}
// Cure cures the [Artifact], producing a directory located at work.
func (a *tarArtifact) Cure(c *CureContext) (err error) {
temp := c.GetTempDir()
func (a *tarArtifact) Cure(t *TContext) (err error) {
temp := t.GetTempDir()
var tr io.ReadCloser
if file, ok := a.f.(File); ok {
if tr, err = c.OpenFile(file); err != nil {
return
}
} else {
var pathname *check.Absolute
if pathname, _, err = c.Cure(a.f); err != nil {
return
}
var entries []os.DirEntry
if entries, err = os.ReadDir(pathname.String()); err != nil {
return
}
if len(entries) != 1 || !entries[0].Type().IsRegular() {
return errors.New(
"input directory does not contain a single regular file",
)
} else {
pathname = pathname.Append(entries[0].Name())
}
if tr, err = os.Open(pathname.String()); err != nil {
return
}
if tr, err = t.Open(a.f); err != nil {
return
}
defer func(f io.ReadCloser) {
@@ -255,9 +229,9 @@ func (a *tarArtifact) Cure(c *CureContext) (err error) {
if err = os.Chmod(p.String(), 0700); err != nil {
return
}
err = os.Rename(p.String(), c.GetWorkDir().String())
err = os.Rename(p.String(), t.GetWorkDir().String())
} else {
err = os.Rename(temp.String(), c.GetWorkDir().String())
err = os.Rename(temp.String(), t.GetWorkDir().String())
}
return
}