Fix history_tree_backup bloat: strip snapshot data from backups
The history_tree_backup (created by _delete_nodes) was storing full snapshot data in every backed-up node — 185MB+ per backup entry. This caused the JSON file to re-bloat to 300MB on every save. Now: - _delete_nodes backs up tree metadata only (no snapshot data) - Load paths strip snapshot data from existing backup entries - Prevents both disk and RAM bloat from backup accumulation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+5
-1
@@ -17,7 +17,11 @@ def _delete_nodes(htree, data, file_path, node_ids, state=None):
|
||||
"""Delete nodes with backup, branch cleanup, re-parenting, and head fallback."""
|
||||
if 'history_tree_backup' not in data:
|
||||
data['history_tree_backup'] = []
|
||||
data['history_tree_backup'].append(json.loads(json.dumps(htree.to_dict())))
|
||||
# Back up tree metadata only (no snapshot data) to avoid bloating JSON
|
||||
backup = json.loads(json.dumps(htree.to_dict()))
|
||||
for node in backup.get('nodes', {}).values():
|
||||
node.pop('data', None)
|
||||
data['history_tree_backup'].append(backup)
|
||||
data['history_tree_backup'] = data['history_tree_backup'][-10:]
|
||||
# Save deleted node parents before removal (needed for branch re-pointing)
|
||||
deleted_parents = {}
|
||||
|
||||
Reference in New Issue
Block a user