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

Method Get

base/database/controller.go:48–79  ·  view source on GitHub ↗

Get returns the record with the given key.

(key string)

Source from the content-addressed store, hash-verified

46
47// Get returns the record with the given key.
48func (c *Controller) Get(key string) (record.Record, error) {
49 if shuttingDown.IsSet() {
50 return nil, ErrShuttingDown
51 }
52
53 if err := c.runPreGetHooks(key); err != nil {
54 return nil, err
55 }
56
57 r, err := c.storage.Get(key)
58 if err != nil {
59 // replace not found error
60 if errors.Is(err, storage.ErrNotFound) {
61 return nil, ErrNotFound
62 }
63 return nil, err
64 }
65
66 r.Lock()
67 defer r.Unlock()
68
69 r, err = c.runPostGetHooks(r)
70 if err != nil {
71 return nil, err
72 }
73
74 if !r.Meta().CheckValidity() {
75 return nil, ErrNotFound
76 }
77
78 return r, nil
79}
80
81// GetMeta returns the metadata of the record with the given key.
82func (c *Controller) GetMeta(key string) (*record.Meta, error) {

Callers

nothing calls this directly

Calls 9

runPreGetHooksMethod · 0.95
runPostGetHooksMethod · 0.95
CheckValidityMethod · 0.80
GetMethod · 0.65
LockMethod · 0.65
UnlockMethod · 0.65
MetaMethod · 0.65
IsSetMethod · 0.45
IsMethod · 0.45

Tested by

no test coverage detected