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

Method SaveSnapshot

pkg/store/json.go:201–217  ·  view source on GitHub ↗

SaveSnapshot 保存快照

(ctx context.Context, agentID string, snapshot types.Snapshot)

Source from the content-addressed store, hash-verified

199
200// SaveSnapshot 保存快照
201func (js *JSONStore) SaveSnapshot(ctx context.Context, agentID string, snapshot types.Snapshot) error {
202 js.mu.Lock()
203 defer js.mu.Unlock()
204
205 if err := js.ensureAgentDir(agentID); err != nil {
206 return err
207 }
208
209 // 创建snapshots目录
210 snapshotsDir := filepath.Join(js.agentDir(agentID), "snapshots")
211 if err := os.MkdirAll(snapshotsDir, 0755); err != nil {
212 return fmt.Errorf("create snapshots directory: %w", err)
213 }
214
215 path := filepath.Join(snapshotsDir, snapshot.ID+".json")
216 return js.saveJSON(path, snapshot)
217}
218
219// LoadSnapshot 加载快照
220func (js *JSONStore) LoadSnapshot(ctx context.Context, agentID string, snapshotID string) (*types.Snapshot, error) {

Callers

nothing calls this directly

Calls 4

ensureAgentDirMethod · 0.95
agentDirMethod · 0.95
saveJSONMethod · 0.95
JoinMethod · 0.45

Tested by

no test coverage detected