aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/pkg/file.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-01-25 14:14:19 +0900
committerOphestra <cat@gensokyo.uk>2026-01-25 14:48:25 +0900
commit334578fddeda6c952b1c2e35829c91c9da72747e (patch)
tree2e3f65188ddbb600cf2f55913dd8f819b10672ea /internal/pkg/file.go
parent20790af71ec9a69a462ecaaa7fc308e3b685383d (diff)
internal/pkg: expose underlying reader
This will be fully implemented in httpArtifact in a future commit. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pkg/file.go')
-rw-r--r--internal/pkg/file.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/internal/pkg/file.go b/internal/pkg/file.go
index 4558eb40..03197c59 100644
--- a/internal/pkg/file.go
+++ b/internal/pkg/file.go
@@ -1,9 +1,11 @@
package pkg
import (
+ "bytes"
"context"
"crypto/sha512"
"fmt"
+ "io"
)
// A fileArtifact is an [Artifact] that cures into data known ahead of time.
@@ -24,10 +26,10 @@ var _ KnownChecksum = new(fileArtifactNamed)
// String returns the caller-supplied reporting name.
func (a *fileArtifactNamed) String() string { return a.name }
-// NewFile returns a [File] that cures into a caller-supplied byte slice.
+// NewFile returns a [FileArtifact] that cures into a caller-supplied byte slice.
//
// Caller must not modify data after NewFile returns.
-func NewFile(name string, data []byte) File {
+func NewFile(name string, data []byte) FileArtifact {
f := fileArtifact(data)
if name != "" {
return &fileArtifactNamed{f, name}
@@ -52,4 +54,6 @@ func (a *fileArtifact) Checksum() Checksum {
}
// Cure returns the caller-supplied data.
-func (a *fileArtifact) Cure(context.Context) ([]byte, error) { return *a, nil }
+func (a *fileArtifact) Cure(context.Context) (io.ReadCloser, error) {
+ return io.NopCloser(bytes.NewReader(*a)), nil
+}