MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / getMetaByPath

Function getMetaByPath

internal/op/meta.go:42–63  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

40 return getMetaByPath(utils.FixAndCleanPath(path))
41}
42func getMetaByPath(path string) (*model.Meta, error) {
43 meta, ok := metaCache.Get(path)
44 if ok {
45 if meta == nil {
46 return meta, errs.MetaNotFound
47 }
48 return meta, nil
49 }
50 meta, err, _ := metaG.Do(path, func() (*model.Meta, error) {
51 _meta, err := db.GetMetaByPath(path)
52 if err != nil {
53 if errors.Is(err, gorm.ErrRecordNotFound) {
54 metaCache.Set(path, nil)
55 return nil, errs.MetaNotFound
56 }
57 return nil, err
58 }
59 metaCache.Set(path, _meta, cache.WithEx[*model.Meta](time.Hour))
60 return _meta, nil
61 })
62 return meta, err
63}
64
65func DeleteMetaById(id uint) error {
66 old, err := db.GetMetaById(id)

Callers 1

GetMetaByPathFunction · 0.85

Calls 4

GetMetaByPathFunction · 0.92
GetMethod · 0.65
DoMethod · 0.65
SetMethod · 0.45

Tested by

no test coverage detected