diff options
| author | Astounds <kirito@disroot.org> | 2026-03-28 16:06:47 -0500 |
|---|---|---|
| committer | Astounds <kirito@disroot.org> | 2026-03-28 16:06:47 -0500 |
| commit | fa7273b328b8cea8b051917f5255a1a712a9e1b9 (patch) | |
| tree | c52212a4675792556c7e595dc4c8a3b3c8e187e4 /youtube/local_playlist.py | |
| parent | a0d10e6a007e6191f1fa34174fd08f4f2c3e580b (diff) | |
| download | yt-local-fa7273b328b8cea8b051917f5255a1a712a9e1b9.tar.lz yt-local-fa7273b328b8cea8b051917f5255a1a712a9e1b9.tar.xz yt-local-fa7273b328b8cea8b051917f5255a1a712a9e1b9.zip | |
fix: race condition in os.makedirs causing worker crashes
Replace check-then-create pattern with exist_ok=True to prevent
FileExistsError when multiple workers initialize simultaneously.
Affects:
- subscriptions.py: open_database()
- watch.py: save_decrypt_cache()
- local_playlist.py: add_to_playlist()
- util.py: fetch_url(), get_visitor_data()
- settings.py: initialization
Fixes Gunicorn worker startup failures in multi-worker deployments.
Diffstat (limited to 'youtube/local_playlist.py')
| -rw-r--r-- | youtube/local_playlist.py | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/youtube/local_playlist.py b/youtube/local_playlist.py index aa3ac27..968f1a6 100644 --- a/youtube/local_playlist.py +++ b/youtube/local_playlist.py @@ -26,8 +26,7 @@ def video_ids_in_playlist(name): def add_to_playlist(name, video_info_list): - if not os.path.exists(playlists_directory): - os.makedirs(playlists_directory) + os.makedirs(playlists_directory, exist_ok=True) ids = video_ids_in_playlist(name) missing_thumbnails = [] with open(os.path.join(playlists_directory, name + ".txt"), "a", encoding='utf-8') as file: |
