# Temporary Files Cleanup Guide

## Overview

This document records the process of identifying and cleaning temporary files in the project, as well as optimizing the `.gitignore` configuration.

## Cleaned Temporary Files

### 1. Code Coverage Related Files

- `build_rs_cov.profraw` - LLVM coverage raw data file
- `coverage/tarpaulin-report.html` - HTML coverage report generated by Tarpaulin

### 2. Important Note: Files NOT to Delete

⚠️ **`.github/workflows/coverage.yml`** - This is a GitHub Actions workflow configuration file, **NOT a temporary file**, should NOT be deleted!

This file's purpose:
- Automatically runs code coverage tests
- Generates coverage reports and badges
- Automatically comments coverage results in PRs
- Uploads coverage data to Codecov

### 2. File Characteristics

| File Type | Extension | Description | Deletable |
|-----------|-----------|-------------|-----------|
| LLVM Coverage Data | `.profraw`, `.profdata` | Raw code coverage data | ✅ |
| Coverage Reports | `.html`, `.xml`, `.lcov`, `.json` | Coverage report files | ✅ |
| Build Artifacts | `target/` | Rust compilation output | ✅ |
| Editor Files | `.swp`, `.swo`, `*~` | Editor temporary files | ✅ |
| System Files | `.DS_Store`, `Thumbs.db` | OS generated files | ✅ |

## Updated .gitignore Rules

```gitignore
# Coverage files / 覆盖率文件
*.profraw
*.profdata
tarpaulin-report.html
cobertura.xml
lcov.info
coverage.json
coverage-summary/
coverage-report-*/

# Rust build artifacts / Rust构建产物
target/
Cargo.lock

# IDE and editor files / IDE和编辑器文件
*.swp
*.swo
*~
.vscode/
*.code-workspace

# OS generated files / 操作系统生成的文件
Thumbs.db
ehthumbs.db

# Temporary files / 临时文件
*.tmp
*.temp
*.log
*.pid
*.lock
*.cache
```

## Cleanup Recommendations

### Regular Cleanup

1. **Coverage Files**: Regenerated after each coverage test run
2. **Build Artifacts**: Clean using `cargo clean`
3. **Temporary Files**: Safe to delete, programs will recreate as needed

### Automated Cleanup

You can create a cleanup script:

```bash
#!/bin/bash
# Clean temporary files
find . -name "*.profraw" -delete
find . -name "*.profdata" -delete
find . -name "tarpaulin-report.html" -delete
cargo clean
```

## Important Notes

- ⚠️ Do not delete configuration files (like `tarpaulin.toml`)
- ⚠️ Do not delete source code and test files
- ✅ Temporary files can be safely deleted, will be regenerated when needed
- ✅ Build artifacts can be restored by recompiling

## Related Documentation

- [Code Coverage Configuration](./code-coverage-en.md)
- [TOML Configuration Fix](./toml-config-fix-en.md)