223bbbefb2d2371d3525d1a9836140cf773ce7c5
Implement simple and correct approach for determining which chunks can be safely removed: When a write overwrites chunks: 1. Update the file tree with new chunk hashes 2. For each old hash, walk the entire tree to check if still in use 3. Only mark chunks for removal if NOT found anywhere in the tree Changes: - Modified file_tree_write() to return removed_hashes array - After updating chunks, check each old_hash with entity_uses_hash() - Walks entire tree from root to verify hash is truly unreferenced - Caller receives array of hashes safe to remove - Only those hashes are added to chunk servers' rem_list This approach is: - Simple: No complex reference counting needed - Correct: Handles deduplication naturally (same content, same hash) - Safe: Only removes chunks with zero references - Easy to understand: Linear tree walk on each write Performance can be optimized later if needed. Correctness first! 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Languages
C
98.4%
Shell
1%
Zig
0.4%
Batchfile
0.2%