From ea92fee4c707066436fda2e2d31560a2f4427523 Mon Sep 17 00:00:00 2001 From: dgw Date: Sat, 29 May 2021 18:28:04 -0500 Subject: [PATCH] tld: fix `.tldcache clear` command breaking `.tld` until manual update Workaround in 7.1.0 is to run `.tldcache update` immediately after `.tldcache clear`, or to run ONLY the `update` subcommand. Note: Backport of #2077 for 7.1.x branch. (7fb3b26f3f80bfc85702c6ea52ad1e2d4b3cf9bd) --- sopel/modules/tld.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/sopel/modules/tld.py b/sopel/modules/tld.py index 694222171e..6ee33567fc 100644 --- a/sopel/modules/tld.py +++ b/sopel/modules/tld.py @@ -382,17 +382,15 @@ def tld_cache_command(bot, trigger): bot.reply("Requesting updated IANA list and Wikipedia data.") update_caches(bot, force=True) elif subcommand == 'clear': - for key in [ - 'tld_list_cache', - 'tld_list_cache_updated', - 'tld_data_cache', - 'tld_data_cache_updated', - ]: - bot.db.delete_plugin_value('tld', key) - try: - del bot.memory[key] - except KeyError: - pass + bot.db.delete_plugin_value('tld', 'tld_data_cache') + bot.memory['tld_data_cache'] = {} + bot.db.delete_plugin_value('tld', 'tld_list_cache') + bot.memory['tld_list_cache'] = [] + bot.db.delete_plugin_value('tld', 'tld_data_cache_updated') + bot.memory['tld_data_cache_updated'] = DEFAULT_CACHE_DATETIME + bot.db.delete_plugin_value('tld', 'tld_list_cache_updated') + bot.memory['tld_list_cache_updated'] = DEFAULT_CACHE_DATETIME + bot.reply("Cleared all cached TLD data.") else: bot.reply(