MCPcopy Index your code
hub / github.com/jetify-com/devbox / loadState

Function loadState

internal/setup/setup.go:304–321  ·  view source on GitHub ↗
(key string)

Source from the content-addressed store, hash-verified

302}
303
304func loadState(key string) state {
305 path := statePath(key)
306 b, err := os.ReadFile(path)
307 if err != nil {
308 if !errors.Is(err, os.ErrNotExist) {
309 err = taskError(key, fmt.Errorf("load state file: %v", err))
310 slog.Error("using empty setup task state due to an error", "err", err, "task", key)
311 }
312 return state{}
313 }
314 loaded := state{}
315 if err := json.Unmarshal(b, &loaded); err != nil {
316 err = taskError(key, fmt.Errorf("load state file %s: %v", path, err))
317 slog.Error("using empty setup task state due to an error", "err", err, "task", key)
318 return state{}
319 }
320 return loaded
321}
322
323func saveState(key string, s state) {
324 path := statePath(key)

Callers 2

StatusFunction · 0.85
runFunction · 0.85

Calls 4

statePathFunction · 0.85
taskErrorFunction · 0.85
IsMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected