Skip to content

Commit

Permalink
tld: fix .tldcache clear command breaking .tld until manual update
Browse files Browse the repository at this point in the history
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.
(7fb3b26)
  • Loading branch information
dgw committed May 31, 2021
1 parent f34fb0f commit ea92fee
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions sopel/modules/tld.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit ea92fee

Please sign in to comment.