diff --git a/daemon.py b/daemon.py index 9c5c585dc..a955041c0 100644 --- a/daemon.py +++ b/daemon.py @@ -280,7 +280,7 @@ from utils import get_image_extensions from utils import media_file_mime_type from utils import getCSS from utils import first_paragraph_from_string -from utils import clearFromPostCaches +from utils import clear_from_post_caches from utils import contains_invalid_chars from utils import is_system_account from utils import set_config_param @@ -4661,9 +4661,9 @@ class PubServer(BaseHTTPRequestHandler): # remove any previous cached news posts newsId = remove_id_ending(post_json_object['object']['id']) newsId = newsId.replace('/', '#') - clearFromPostCaches(base_dir, - self.server.recent_posts_cache, - newsId) + clear_from_post_caches(base_dir, + self.server.recent_posts_cache, + newsId) # save the news post save_json(post_json_object, post_filename) diff --git a/newsdaemon.py b/newsdaemon.py index 53595f57f..9ce35e0de 100644 --- a/newsdaemon.py +++ b/newsdaemon.py @@ -31,7 +31,7 @@ from utils import get_full_domain from utils import load_json from utils import save_json from utils import get_status_number -from utils import clearFromPostCaches +from utils import clear_from_post_caches from utils import dangerous_markup from utils import local_actor_url from inbox import storeHashTags @@ -730,7 +730,7 @@ def _convertRSStoActivityPub(base_dir: str, http_prefix: str, http_prefix, domain_full, blog, translate) - clearFromPostCaches(base_dir, recent_posts_cache, post_id) + clear_from_post_caches(base_dir, recent_posts_cache, post_id) if save_json(blog, filename): _updateFeedsOutboxIndex(base_dir, domain, post_id + '.json') diff --git a/utils.py b/utils.py index 680c17920..96e50e8fb 100644 --- a/utils.py +++ b/utils.py @@ -1296,8 +1296,8 @@ def locate_news_arrival(base_dir: str, domain: str, return None -def clearFromPostCaches(base_dir: str, recent_posts_cache: {}, - post_id: str) -> None: +def clear_from_post_caches(base_dir: str, recent_posts_cache: {}, + post_id: str) -> None: """Clears cached html for the given post, so that edits to news will appear """ @@ -1308,13 +1308,13 @@ def clearFromPostCaches(base_dir: str, recent_posts_cache: {}, continue if acct.startswith('inbox@'): continue - cacheDir = os.path.join(base_dir + '/accounts', acct) - post_filename = cacheDir + filename + cache_dir = os.path.join(base_dir + '/accounts', acct) + post_filename = cache_dir + filename if os.path.isfile(post_filename): try: os.remove(post_filename) except OSError: - print('EX: clearFromPostCaches file not removed ' + + print('EX: clear_from_post_caches file not removed ' + str(post_filename)) # if the post is in the recent posts cache then remove it if recent_posts_cache.get('index'): @@ -1346,15 +1346,15 @@ def locate_post(base_dir: str, nickname: str, domain: str, # search boxes boxes = ('inbox', 'outbox', 'tlblogs') - accountDir = acct_dir(base_dir, nickname, domain) + '/' + account_dir = acct_dir(base_dir, nickname, domain) + '/' for boxName in boxes: - post_filename = accountDir + boxName + '/' + postUrl + post_filename = account_dir + boxName + '/' + postUrl if os.path.isfile(post_filename): return post_filename # check news posts - accountDir = base_dir + '/accounts/news' + '@' + domain + '/' - post_filename = accountDir + 'outbox/' + postUrl + account_dir = base_dir + '/accounts/news' + '@' + domain + '/' + post_filename = account_dir + 'outbox/' + postUrl if os.path.isfile(post_filename): return post_filename