MCPcopy
hub / github.com/cli/cli / Create

Method Create

pkg/cmd/run/view/view.go:47–64  ·  view source on GitHub ↗
(key string, content io.Reader)

Source from the content-addressed store, hash-verified

45}
46
47func (c RunLogCache) Create(key string, content io.Reader) error {
48 if err := os.MkdirAll(c.cacheDir, 0755); err != nil {
49 return fmt.Errorf("creating cache directory: %v", err)
50 }
51
52 out, err := os.Create(c.filepath(key))
53 if err != nil {
54 return fmt.Errorf("creating cache entry: %v", err)
55 }
56 defer out.Close()
57
58 if _, err := io.Copy(out, content); err != nil {
59 return fmt.Errorf("writing cache entry: %v", err)
60
61 }
62
63 return nil
64}
65
66func (c RunLogCache) Open(key string) (*zip.ReadCloser, error) {
67 r, err := zip.OpenReader(c.filepath(key))

Callers 1

TestRunLogFunction · 0.95

Calls 5

filepathMethod · 0.95
ErrorfMethod · 0.65
CreateMethod · 0.65
CloseMethod · 0.65
CopyMethod · 0.45

Tested by 1

TestRunLogFunction · 0.76