MCPcopy Create free account
hub / github.com/Tong89/smartNode / snapshot_export

Function snapshot_export

backend/api.py:1355–1371  ·  view source on GitHub ↗

将内存中的快照以 JSON 文件形式下载。

()

Source from the content-addressed store, hash-verified

1353
1354@app.route('/api/snapshot/export', methods=['GET'])
1355def snapshot_export():
1356 """将内存中的快照以 JSON 文件形式下载。"""
1357 if _saved_snapshot is None:
1358 return error_response("NOT_FOUND", "尚未保存任何快照,请先调用 /api/snapshot/save")
1359 try:
1360 content = _SnapshotManager.to_json(_saved_snapshot)
1361 except Exception:
1362 logger.exception("快照导出失败")
1363 return error_response("INTERNAL_ERROR")
1364 label = (_saved_snapshot.get("label") or "snapshot").replace(" ", "_")[:32]
1365 filename = f"{label}.snapshot.json"
1366 return app.response_class(
1367 response=content,
1368 status=200,
1369 mimetype="application/json",
1370 headers={"Content-Disposition": f'attachment; filename="{filename}"'},
1371 )
1372
1373
1374@app.route('/api/snapshot/import', methods=['POST'])

Callers

nothing calls this directly

Calls 3

error_responseFunction · 0.90
to_jsonMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected