fix: prevent infinite retry loop on PermissionError in downloader#88
Conversation
When os.makedirs() fails with PermissionError (e.g., trying to create /opt/podcasts without permissions), the exception occurred before the episode was marked as failed. This left the episode in "pending" state, causing it to be picked up again on the next iteration in an infinite loop. Changes: - Handle PermissionError in download_episode() and _download_episode_async() by marking the episode as failed and returning a failed DownloadResult - Improve error message in constructor to mention PODCAST_DOWNLOAD_DIRECTORY - Add tests for PermissionError handling
WalkthroughThe pull request adds PermissionError handling for directory creation across the EpisodeDownloader class. During initialization, permission errors raise an exception with a descriptive message. During episode downloads (both sync and async paths), permission errors are logged, the download is marked as failed in the repository, and a failed result is returned. Comprehensive tests validate these error scenarios. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
🧹 Recent nitpick comments
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used📓 Path-based instructions (3)**/*.py📄 CodeRabbit inference engine (AGENTS.md)
Files:
tests/test_*.py📄 CodeRabbit inference engine (AGENTS.md)
Files:
src/**/*.py📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧬 Code graph analysis (2)tests/test_downloader.py (1)
src/podcast/downloader.py (2)
🪛 Ruff (0.14.13)src/podcast/downloader.py102-105: Avoid specifying long messages outside the exception class (TRY003) 166-166: Use Replace with (TRY400) 431-431: Use Replace with (TRY400) 🔇 Additional comments (2)
✏️ Tip: You can disable this entire section by setting Comment |
Summary
os.makedirs()fails with PermissionError during downloadsProblem
When the download directory (e.g.,
/opt/podcasts) couldn't be created due to permission issues, thePermissionErrorwas raised before the episode was marked as started or failed. This left the episode indownload_status="pending", causing:Test plan
TestEpisodeDownloaderPermissionErrorsmark_download_startedis not called on PermissionErrorSummary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.