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

Method Delete

pkg/memory/preference_storage.go:100–113  ·  view source on GitHub ↗

Delete 实现 PreferenceStorage 接口

(ctx context.Context, userID string)

Source from the content-addressed store, hash-verified

98
99// Delete 实现 PreferenceStorage 接口
100func (fs *FilePreferenceStorage) Delete(ctx context.Context, userID string) error {
101 fs.mu.Lock()
102 defer fs.mu.Unlock()
103
104 filePath := filepath.Join(fs.dir, userID+".json")
105 if err := os.Remove(filePath); err != nil {
106 if os.IsNotExist(err) {
107 return nil // 文件不存在视为成功
108 }
109 return fmt.Errorf("failed to delete file: %w", err)
110 }
111
112 return nil
113}
114
115// List 实现 PreferenceStorage 接口
116func (fs *FilePreferenceStorage) List(ctx context.Context) ([]string, error) {

Callers 1

Calls 2

JoinMethod · 0.45
RemoveMethod · 0.45

Tested by 1