INNER CODE UNIT · Python

size_kb

Dicklesworthstone/claude_code_agent_farm · claude_code_agent_farm.py:833

                size_kb = backup_file.stat().st_size / 1024
                console.print(f"[green]✓ Backed up Claude settings to {backup_file.name} ({size_kb:.1f} KB)[/green]")
            
            # Clean up old backups (keep last 10)
            self._cleanup_old_backups(backup_dir, keep_count=10)
            
            return str(backup_file)
        except Exception as e:
            console.print(f"[red]Error: Could not backup Claude directory: {e}[/red]")
            return None

    def _cleanup_old_backups(self, backup_dir: Path, keep_count: int = 10, max_total_mb: int = 200) -> None:
        """Remove old backups, keeping only the most recent ones and enforcing size limit"""
        try:
            # Find all backup files (both essential and full)
            backups = sorted(backup_dir.glob("claude_backup_*.tar.gz"), key=lambda p: p.stat().st_mtime, reverse=True)
            
            # Calculate total size and remove old backups based on both count and size limits

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…