MCPcopy
hub / github.com/caddyserver/certmagic / Store

Method Store

filestorage.go:80–98  ·  view source on GitHub ↗

Store saves value at key.

(_ context.Context, key string, value []byte)

Source from the content-addressed store, hash-verified

78
79// Store saves value at key.
80func (s *FileStorage) Store(_ context.Context, key string, value []byte) error {
81 filename := s.Filename(key)
82 err := os.MkdirAll(filepath.Dir(filename), 0700)
83 if err != nil {
84 return err
85 }
86 fp, err := atomicfile.New(filename, 0o600)
87 if err != nil {
88 return err
89 }
90 _, err = fp.Write(value)
91 if err != nil {
92 // cancel the write
93 fp.Cancel()
94 return err
95 }
96 // close, thereby flushing the write
97 return fp.Close()
98}
99
100// Load retrieves the value at key.
101func (s *FileStorage) Load(_ context.Context, key string) ([]byte, error) {

Callers 2

TestFileStorageStoreLoadFunction · 0.95

Calls 5

FilenameMethod · 0.95
NewFunction · 0.92
WriteMethod · 0.80
CloseMethod · 0.80
CancelMethod · 0.65

Tested by 2

TestFileStorageStoreLoadFunction · 0.76