diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-01-09 01:51:39 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-01-09 05:20:34 +0900 |
| commit | f7124667145d1f7c614d9fc644bc07bb6174454a (patch) | |
| tree | 9585573da6d016a27ce7fd066b795f611d1ce877 /internal/pkg/tar.go | |
| parent | f2430b5f5ef7ac0361d1c4976b7ec7bebaa15f63 (diff) | |
internal/pkg: move dependency flooding to cache
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>
Diffstat (limited to 'internal/pkg/tar.go')
| -rw-r--r-- | internal/pkg/tar.go | 42 |
1 files changed, 8 insertions, 34 deletions
diff --git a/internal/pkg/tar.go b/internal/pkg/tar.go index 968e8a0d..dc15a154 100644 --- a/internal/pkg/tar.go +++ b/internal/pkg/tar.go @@ -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 } |
