From 8c86f9d3eca2c045a12f77bb28ebcc1956f49845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Haukur=20P=C3=A1ll?= Date: Sat, 22 Jan 2022 15:43:32 +0000 Subject: [PATCH] Cache datetime handling fixed. Now longer updating cache information if we did not download anything new. --- src/ruv_dl/ruv_client.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ruv_dl/ruv_client.py b/src/ruv_dl/ruv_client.py index 030bbe4..13ffa4f 100644 --- a/src/ruv_dl/ruv_client.py +++ b/src/ruv_dl/ruv_client.py @@ -178,6 +178,7 @@ def load_programs( ) -> Programs: """Load the programs by either loading from cache or by querying ruv.is.""" last_fetched = load_last_fetched(last_fetched_file) + fetched = False # We have not fetched before if last_fetched is None: force_reload = True @@ -188,13 +189,16 @@ def load_programs( force_reload = True if force_reload: programs = RUVClient().get_all_programs() + fetched = True else: try: programs = load_programs_cache(programs_cache) except FileNotFoundError: programs = RUVClient().get_all_programs() - save_programs_cache(programs_cache, programs) - save_last_fetched(last_fetched_file) + fetched = True + if fetched: + save_programs_cache(programs_cache, programs) + save_last_fetched(last_fetched_file) num_episodes = sum([len(program["episodes"]) for program in programs.values()]) log.info(f"Loaded {len(programs)} programs and {num_episodes} episodes") return programs