games:cleanup-downloads
Cleans up old game version downloads, keeping only the latest version to save storage space.
Overview
This command removes outdated game download files from storage while preserving the most recent version of each game. It helps manage disk space by removing files that are no longer needed for analysis or processing.
Usage
php artisan games:cleanup-downloads [options]
Options
- --game-id=ID
- ID of the specific game to clean up.
- --game-name=NAME
- Name (or part of name) of the game(s) to clean up.
- --all
- Clean up downloads for all games.
Cleanup Logic
The command follows this cleanup process:
- Identifies game versions for the specified scope
- Determines latest version for each game
- Marks older versions for cleanup
- Removes download files while preserving metadata
- Updates database records to reflect cleanup status
- Reports storage savings achieved
Examples
php artisan games:cleanup-downloads --game-id=123
Cleans up old downloads for game ID 123, keeping only the latest version.
php artisan games:cleanup-downloads --game-name="Doki Doki"
Cleans up downloads for all games with "Doki Doki" in the name.
php artisan games:cleanup-downloads --all
Cleans up old downloads for all games in the database.
php artisan games:cleanup-downloads --all -v
Shows detailed information about each file being removed.
When to Use
Recommended Usage Scenarios
- Regular maintenance to manage storage space
- Before storage capacity reaches limits
- After bulk game imports or updates
- When preparing for system backups
- During server maintenance windows
Safety Features
The command includes several safety mechanisms:
Data Preservation
- Metadata Retention: Database records remain intact
- Latest Version Protection: Never removes the most recent version
- Analysis Data: Preserves processed statistics and character data
Verification Checks
- File Existence: Verifies files exist before attempting removal
- Permission Checks: Ensures write access to storage directories
- Database Consistency: Maintains referential integrity
Storage Impact
| File Type | Typical Size | Cleanup Impact |
| Game Archives | 50-500 MB | High storage savings |
| Extracted Files | 100-1000 MB | Very high savings |
| Processing Temp | 10-100 MB | Medium savings |
| Metadata | Preserved (not cleaned) |
Cleanup Scope
The command can target different scopes:
Single Game (--game-id)
- Fastest execution
- Precise control
- Minimal system impact
Named Games (--game-name)
- Pattern-based selection
- Useful for series or collections
- Moderate system impact
All Games (--all)
- Maximum storage savings
- Longest execution time
- Highest system impact
Recovery
If files need to be restored after cleanup:
- Re-download from original sources (if available)
- Restore from backups (if backup strategy includes downloads)
- Re-import using other commands if source files exist
Warning: Cleanup is irreversible. Ensure you have alternative access to game files if needed for future analysis.
Related Commands
- games:refresh: Re-download game files
- games:reimport-version: Reprocess existing files