Skip to content

Commit e26dee0

Browse files
authored
Merge pull request #4 from DiamondGotCat/copilot/fix-3
Add comprehensive GitHub Copilot instructions for FastGet repository
2 parents 05435c2 + 7919dc9 commit e26dee0

2 files changed

Lines changed: 173 additions & 2 deletions

File tree

.github/copilot-instructions.md

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# FastGet
2+
FastGet is a Python CLI application that downloads files using multiple threads for faster download speeds. It supports HTTP range requests to download file parts in parallel and merges them together.
3+
4+
Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.
5+
6+
## Working Effectively
7+
- Bootstrap, setup, and validate the repository:
8+
- `python3 --version` -- verify Python 3.12+ is available
9+
- `python3 -m pip install --upgrade pip`
10+
- `python3 -m pip install -r requirements.txt` -- installs requests and rich libraries
11+
- `python3 -m py_compile fastget.py` -- validate Python syntax
12+
- Build standalone executable:
13+
- `python3 -m pip install pyinstaller ordered-set zstandard pefile` -- install build dependencies
14+
- `time pyinstaller --onefile --distpath dist --name fastget fastget.py` -- NEVER CANCEL: takes 15-25 seconds. Set timeout to 60+ seconds.
15+
- Run the application:
16+
- Python script: `python3 fastget.py`
17+
- Built executable: `./dist/fastget`
18+
- Both versions prompt for: URL, output filename (optional), number of threads (default 8)
19+
20+
## Validation
21+
- ALWAYS test functionality manually after making changes using the validation scenarios below.
22+
- The application works correctly but network restrictions in CI environments may prevent downloads.
23+
- ALWAYS run through at least one complete download scenario after making changes when network access is available.
24+
- ALWAYS run `python3 -m py_compile fastget.py` before committing to validate Python syntax.
25+
- Build validation: `time pyinstaller --onefile --distpath dist --name fastget fastget.py` should complete in 15-25 seconds.
26+
27+
## Manual Validation Scenarios
28+
When network access is available, test these scenarios:
29+
30+
### Basic Download Test
31+
```bash
32+
python3 fastget.py
33+
# When prompted:
34+
# URL: https://speed.hetzner.de/1KB.bin
35+
# Save as: test.bin (or press Enter)
36+
# Threads: 4
37+
# Expected: Downloads 1KB file quickly with progress bar
38+
```
39+
40+
### Multi-threading Test
41+
```bash
42+
python3 fastget.py
43+
# When prompted:
44+
# URL: https://speed.hetzner.de/10MB.bin
45+
# Save as: large_test.bin
46+
# Threads: 8
47+
# Expected: Downloads 10MB file using multiple threads with progress
48+
```
49+
50+
### Single Thread Fallback Test
51+
```bash
52+
python3 fastget.py
53+
# When prompted:
54+
# URL: https://httpbin.org/bytes/1024
55+
# Save as: single_thread.bin
56+
# Threads: 4
57+
# Expected: Detects no range support, falls back to single thread
58+
```
59+
60+
### Executable Test
61+
```bash
62+
./dist/fastget
63+
# Run same tests as above using the built executable
64+
# Expected: Same behavior as Python script
65+
```
66+
67+
### Validation Criteria
68+
✓ Application starts without errors
69+
✓ Prompts for URL, filename, and threads
70+
✓ Shows rich progress bar during download
71+
✓ Creates output file with correct size
72+
✓ Handles range/non-range servers correctly
73+
✓ Multi-threading works when supported
74+
✓ Single-thread fallback works when needed
75+
76+
## Build Process Details
77+
- Build command: `pyinstaller --onefile --distpath dist --name fastget fastget.py`
78+
- NEVER CANCEL: Build takes 15-25 seconds. ALWAYS set timeout to 60+ seconds minimum.
79+
- Output: Single executable file in `dist/fastget` (Linux/macOS) or `dist/fastget.exe` (Windows)
80+
- Size: Approximately 14MB for Linux build
81+
- Dependencies embedded: Python runtime, requests, rich, and all required libraries
82+
83+
## Common Tasks
84+
The following are outputs from frequently run commands. Reference them instead of viewing, searching, or running bash commands to save time.
85+
86+
### Repository Structure
87+
```
88+
ls -la
89+
.
90+
..
91+
.git/
92+
.github/
93+
workflows/
94+
fastget-build.yml # CI build workflow
95+
LICENSE # MIT License
96+
README.md # Basic project description
97+
fastget.py # Main Python application (106 lines)
98+
requirements.txt # Python dependencies (requests, rich)
99+
```
100+
101+
### Dependencies
102+
```
103+
cat requirements.txt
104+
requests
105+
rich
106+
```
107+
108+
### Main Application Structure
109+
```
110+
fastget.py contains:
111+
- VERSION = "2.0"
112+
- Interactive prompts for URL, output file, threads
113+
- get_file_size() - checks Content-Length and Accept-Ranges headers
114+
- download_range() - downloads file chunk with Range header
115+
- merge_files() - combines downloaded parts into final file
116+
- main() - orchestrates the download process
117+
```
118+
119+
### Build Dependencies
120+
```
121+
pip install pyinstaller ordered-set zstandard pefile
122+
```
123+
124+
## CI/CD Information
125+
- GitHub Actions workflow: `.github/workflows/fastget-build.yml`
126+
- Builds on release for multiple platforms: Windows, macOS, Linux (both x64 and ARM64)
127+
- Uses Python 3.12
128+
- Build artifacts uploaded as GitHub release assets
129+
- Build time in CI: varies by platform, allow 5-10 minutes for full matrix
130+
131+
## Known Limitations
132+
- No unit tests exist in the repository
133+
- No linting tools configured (flake8, pylint not available)
134+
- Network restrictions in some CI environments prevent download testing
135+
- Application is interactive only - no command-line argument support
136+
- No --help option available
137+
138+
## Code Quality
139+
- Always run `python3 -m py_compile fastget.py` to validate syntax before committing
140+
- The code follows basic Python conventions
141+
- Uses rich library for progress display and user prompts
142+
- Implements proper error handling for network requests
143+
- Thread-safe file writing with part files merged at the end
144+
145+
## Troubleshooting
146+
- Import errors: Ensure `pip install -r requirements.txt` completed successfully
147+
- Build errors: Verify all build dependencies are installed
148+
- Network errors during testing: Expected in restricted environments, test manually when possible
149+
- Permission errors: Ensure executable permissions on `dist/fastget` after build

.gitignore

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.so
6+
7+
# PyInstaller
8+
build/
9+
dist/
10+
*.spec
11+
12+
# Temporary files
13+
*.tmp
14+
*.temp
15+
.DS_Store
16+
Thumbs.db
17+
118
# Python cache files
219
__pycache__/
320
*.pyc
@@ -10,12 +27,17 @@ venv/
1027
env/
1128
ENV/
1229

13-
# IDE files
30+
# IDE
1431
.vscode/
1532
.idea/
1633
*.swp
1734
*.swo
1835

36+
# Virtual environments
37+
venv/
38+
env/
39+
.env
40+
=======
1941
# OS files
2042
.DS_Store
2143
Thumbs.db
@@ -33,4 +55,4 @@ htmlcov/
3355
# Temporary files
3456
*.tmp
3557
*.temp
36-
.part*
58+
.part*

0 commit comments

Comments
 (0)