MCPcopy Index your code
hub / github.com/docker/docker-agent / loadFromFile

Function loadFromFile

pkg/cache/cache.go:261–276  ·  view source on GitHub ↗

loadFromFile decodes path into entries. A missing file is not an error and leaves entries empty.

(path string, entries map[string]string)

Source from the content-addressed store, hash-verified

259// loadFromFile decodes path into entries. A missing file is not an error
260// and leaves entries empty.
261func loadFromFile(path string, entries map[string]string) error {
262 data, err := os.ReadFile(path)
263 switch {
264 case errors.Is(err, os.ErrNotExist):
265 return nil
266 case err != nil:
267 return fmt.Errorf("reading cache file %q: %w", path, err)
268 }
269 if len(data) == 0 {
270 return nil
271 }
272 if err := json.Unmarshal(data, &entries); err != nil {
273 return fmt.Errorf("loading cache file %q: %w", path, err)
274 }
275 return nil
276}
277
278// mtimeOf returns the file modification time at path, or the zero value
279// if path doesn't exist or can't be stat'd.

Callers 3

NewFunction · 0.85
persistToDiskMethod · 0.85
maybeReloadMethod · 0.85

Calls 1

ReadFileMethod · 0.80

Tested by

no test coverage detected