diff options
Diffstat (limited to 'internal/pkg/pkg.go')
| -rw-r--r-- | internal/pkg/pkg.go | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/internal/pkg/pkg.go b/internal/pkg/pkg.go index ae3a8185..f837fade 100644 --- a/internal/pkg/pkg.go +++ b/internal/pkg/pkg.go @@ -478,6 +478,8 @@ type KnownIdent interface { // [Artifact]. This value must be known ahead of time and guaranteed to be // unique without having obtained the full contents of the [Artifact]. ID() ID + + Artifact } // KnownChecksum is optionally implemented by [Artifact] for an artifact with @@ -489,6 +491,8 @@ type KnownChecksum interface { // // Result must remain identical across multiple invocations. Checksum() Checksum + + Artifact } // CuresExempt is optionally implemented for an artifact exempt to the @@ -506,6 +510,12 @@ type CuresExempt interface { // FileArtifact does not support fine-grained cancellation. Its context is // inherited from the first [TrivialArtifact] or [FloodArtifact] that opens it. type FileArtifact interface { + // IsExecutable returns whether the resulting filesystem entry should be made + // executable, if the [FileArtifact] is cured to the on-disk cache. + // + // Result must remain identical across multiple invocations. + IsExecutable() bool + // Cure returns [io.ReadCloser] of the full contents of [FileArtifact]. If // [FileArtifact] implements [KnownChecksum], Cure is responsible for // validating any data it produces and must return [ChecksumMismatchError] @@ -515,7 +525,8 @@ type FileArtifact interface { // // Callers are responsible for closing the resulting [io.ReadCloser]. // - // Result must remain identical across multiple invocations. + // The resulting [io.ReadCloser] across multiple invocations must have + // identical behaviour. Cure(r *RContext) (io.ReadCloser, error) Artifact @@ -2208,12 +2219,17 @@ func (c *Cache) cure(a Artifact, curesExempt, rebuild bool) ( return } + perm := os.FileMode(0400) + if f.IsExecutable() { + perm = 0500 + } + work := c.base.Append(dirWork, ids) var w *os.File if w, err = os.OpenFile( work.String(), os.O_CREATE|os.O_EXCL|os.O_WRONLY, - 0400, + perm, ); err != nil { return } |
