diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-04-18 02:28:28 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-04-18 02:28:28 +0530 |
commit | 19a0394044bfad36cd665450271b8eb048a41c02 (patch) | |
tree | 0db2a09d23293b47f1cc3bbd3a5989120f660c37 /yt_dlp/cache.py | |
parent | b6dc37fe2aee167bf11f863f960a4888f4886718 (diff) | |
download | hypervideo-pre-19a0394044bfad36cd665450271b8eb048a41c02.tar.lz hypervideo-pre-19a0394044bfad36cd665450271b8eb048a41c02.tar.xz hypervideo-pre-19a0394044bfad36cd665450271b8eb048a41c02.zip |
[cleanup] Misc cleanup and refactor (#2173)
Diffstat (limited to 'yt_dlp/cache.py')
-rw-r--r-- | yt_dlp/cache.py | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/yt_dlp/cache.py b/yt_dlp/cache.py index 0cac3ee88..e3f8a7dab 100644 --- a/yt_dlp/cache.py +++ b/yt_dlp/cache.py @@ -1,3 +1,4 @@ +import contextlib import errno import json import os @@ -57,7 +58,7 @@ class Cache: return default cache_fn = self._get_cache_fn(section, key, dtype) - try: + with contextlib.suppress(OSError): try: with open(cache_fn, encoding='utf-8') as cachef: self._ydl.write_debug(f'Loading {section}.{key} from cache') @@ -68,8 +69,6 @@ class Cache: except OSError as oe: file_size = str(oe) self._ydl.report_warning(f'Cache retrieval from {cache_fn} failed ({file_size})') - except OSError: - pass # No cache available return default |