refactor: split mutex, add download queue, wire context cancellation
All checks were successful
CI / build (push) Successful in 53s

- Split single sync.Mutex into per-map mutexes (activeJobs, stepStates,
  rateLimiter, pendingInput, cancelFuncs) to reduce contention
- Add download semaphore (channel-buffered, 3 concurrent) as worker pool
- Add cancelFuncs map with context cancellation wired into download
  goroutines for clean shutdown
- Replace playlist busy-poll (500ms sleep loop) with synchronous
  runDownload + Done channel for completion tracking
- Use full UUID for job IDs instead of 8-char prefix
- Download thumbnail URL to temp file before sending (InputFileUpload)
- Change MAX_FILE_SIZE_MB default from 2000 to 50
- Clean up cancel funcs after normal download completion
This commit is contained in:
2026-06-25 23:23:19 +03:30
parent 3290bb55c0
commit dfe946a41b
8 changed files with 233 additions and 111 deletions

View File

@@ -41,7 +41,7 @@ Copy `.env.example` to `.env` and configure:
| `HTTPS_PROXY` | empty | Outbound HTTPS proxy |
| `DB_PATH` | `data/uptodown.db` | SQLite database path |
| `DOWNLOAD_DIR` | `/tmp/uptodown` | Temporary download directory |
| `MAX_FILE_SIZE_MB` | `2000` | Maximum upload file size in MB |
| `MAX_FILE_SIZE_MB` | `50` | Maximum upload file size in MB |
| `COOKIES_FILE` | empty | Path to cookies.txt for auth |
| `TZ` | `UTC` | Timezone |
| `BOT_ALLOWED_USERS` | empty | Comma-separated allowed user IDs |