From 9c6e19fb3bf231df26f59a6dd004d2147fac329e Mon Sep 17 00:00:00 2001 From: dekzter Date: Fri, 25 Apr 2025 13:46:58 -0400 Subject: [PATCH] clean up old cache files when we refresh epg from remote source --- apps/epg/tasks.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/epg/tasks.py b/apps/epg/tasks.py index a28db282..74411bdb 100644 --- a/apps/epg/tasks.py +++ b/apps/epg/tasks.py @@ -62,6 +62,9 @@ def fetch_xmltv(source): if not source.url: return + if os.path.exists(source.get_cache_file()): + os.remove(source.get_cache_file()) + logger.info(f"Fetching XMLTV data from source: {source.name}") try: response = requests.get(source.url, timeout=30) @@ -160,7 +163,7 @@ def parse_programs_for_tvg_id(epg_id): file_path = epg_source.file_path if not file_path: file_path = epg_source.get_cache_file() - if not os.exists(file_path): + if not os.path.exists(file_path): fetch_xmltv(epg_source) # Read entire file (decompress if .gz)