MCPcopy Create free account
hub / github.com/astercloud/aster / Exists

Method Exists

pkg/store/json.go:459–473  ·  view source on GitHub ↗

Exists 检查资源是否存在

(ctx context.Context, collection, key string)

Source from the content-addressed store, hash-verified

457
458// Exists 检查资源是否存在
459func (js *JSONStore) Exists(ctx context.Context, collection, key string) (bool, error) {
460 js.mu.RLock()
461 defer js.mu.RUnlock()
462
463 path := filepath.Join(js.collectionDir(collection), key+".json")
464 _, err := os.Stat(path)
465 if err != nil {
466 if os.IsNotExist(err) {
467 return false, nil
468 }
469 return false, fmt.Errorf("stat file: %w", err)
470 }
471
472 return true, nil
473}
474
475// DecodeValue 将 any 解码为具体类型
476func DecodeValue(src any, dest any) error {

Callers

nothing calls this directly

Calls 3

collectionDirMethod · 0.95
StatMethod · 0.65
JoinMethod · 0.45

Tested by

no test coverage detected