MCPcopy
hub / github.com/safing/portmaster / GetMeta

Method GetMeta

base/database/controller.go:82–115  ·  view source on GitHub ↗

GetMeta returns the metadata of the record with the given key.

(key string)

Source from the content-addressed store, hash-verified

80
81// GetMeta returns the metadata of the record with the given key.
82func (c *Controller) GetMeta(key string) (*record.Meta, error) {
83 if shuttingDown.IsSet() {
84 return nil, ErrShuttingDown
85 }
86
87 var m *record.Meta
88 var err error
89 if metaDB, ok := c.storage.(storage.MetaHandler); ok {
90 m, err = metaDB.GetMeta(key)
91 if err != nil {
92 // replace not found error
93 if errors.Is(err, storage.ErrNotFound) {
94 return nil, ErrNotFound
95 }
96 return nil, err
97 }
98 } else {
99 r, err := c.storage.Get(key)
100 if err != nil {
101 // replace not found error
102 if errors.Is(err, storage.ErrNotFound) {
103 return nil, ErrNotFound
104 }
105 return nil, err
106 }
107 m = r.Meta()
108 }
109
110 if !m.CheckValidity() {
111 return nil, ErrNotFound
112 }
113
114 return m, nil
115}
116
117// Put saves a record in the database, executes any registered
118// pre-put hooks and finally send an update to all subscribers.

Callers

nothing calls this directly

Calls 6

CheckValidityMethod · 0.95
GetMetaMethod · 0.65
GetMethod · 0.65
MetaMethod · 0.65
IsSetMethod · 0.45
IsMethod · 0.45

Tested by

no test coverage detected