MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / LoadRegistry

Function LoadRegistry

internal/cli/registry.go:44–64  ·  view source on GitHub ↗

LoadRegistry reads the installation registry from disk. Returns an empty registry if the file doesn't exist.

()

Source from the content-addressed store, hash-verified

42// LoadRegistry reads the installation registry from disk.
43// Returns an empty registry if the file doesn't exist.
44func LoadRegistry() (*Registry, error) {
45 path, err := registryPath()
46 if err != nil {
47 return &Registry{}, nil
48 }
49
50 data, err := os.ReadFile(path)
51 if err != nil {
52 if os.IsNotExist(err) {
53 return &Registry{}, nil
54 }
55 return nil, fmt.Errorf("read registry: %w", err)
56 }
57
58 var reg Registry
59 if err := json.Unmarshal(data, &reg); err != nil {
60 // Corrupted file — start fresh
61 return &Registry{}, nil
62 }
63 return &reg, nil
64}
65
66// Save writes the registry to disk.
67func (r *Registry) Save() error {

Callers 3

installListFunction · 0.92
installUpdateFunction · 0.92
recordInstallationFunction · 0.92

Calls 1

registryPathFunction · 0.85

Tested by

no test coverage detected