mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-11-23 04:14:05 +08:00
Cache one concrete client per connection-settings key at module level and reuse it across `async with DownloadClient()` blocks instead of logging in on enter and out on exit every operation (~1/min from the rename loop). QbDownloader.auth is now idempotent — a live, authenticated client short-circuits without re-posting login — and data operations go through a _request wrapper that re-authenticates once and retries on a 403 (expired session). __aexit__ no longer logs out; a new shutdown() module function tears the cached client down (wired up by the Phase 5 composition root). MockDownloader/Aria2Downloader gain the same auth idempotency. When connection settings change, the stale client is retired and closed lazily on the next enter. A failed fresh login still closes the pool and drops the cache entry before raising (leak fix, #1043). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014w1Z6Nxy6XTRgkFXqPr9Zh