diff --git a/bookmarks.py b/bookmarks.py index c330c6ffe..d0153a5e6 100644 --- a/bookmarks.py +++ b/bookmarks.py @@ -15,7 +15,7 @@ from utils import remove_domain_port from utils import has_users_path from utils import get_full_domain from utils import removeIdEnding -from utils import removePostFromCache +from utils import remove_post_from_cache from utils import urlPermitted from utils import getNicknameFromActor from utils import getDomainFromActor @@ -57,7 +57,7 @@ def undoBookmarksCollectionEntry(recent_posts_cache: {}, print('EX: undoBookmarksCollectionEntry ' + 'unable to delete cached post file ' + str(cachedPostFilename)) - removePostFromCache(post_json_object, recent_posts_cache) + remove_post_from_cache(post_json_object, recent_posts_cache) # remove from the index bookmarksIndexFilename = \ @@ -177,7 +177,7 @@ def updateBookmarksCollection(recent_posts_cache: {}, print('EX: updateBookmarksCollection ' + 'unable to delete cached post ' + str(cachedPostFilename)) - removePostFromCache(post_json_object, recent_posts_cache) + remove_post_from_cache(post_json_object, recent_posts_cache) if not post_json_object.get('object'): if debug: diff --git a/daemon.py b/daemon.py index 8fa2d771b..f81d12cf2 100644 --- a/daemon.py +++ b/daemon.py @@ -292,7 +292,7 @@ from utils import isBlogPost from utils import removeAvatarFromCache from utils import locate_post from utils import get_cached_post_filename -from utils import removePostFromCache +from utils import remove_post_from_cache from utils import getNicknameFromActor from utils import getDomainFromActor from utils import getStatusNumber @@ -560,8 +560,8 @@ class PubServer(BaseHTTPRequestHandler): 'unable to delete ' + cachedPostFilename) # remove from memory cache - removePostFromCache(post_json_object, - self.server.recent_posts_cache) + remove_post_from_cache(post_json_object, + self.server.recent_posts_cache) else: print('ERROR: unable to post vote to outbox') else: @@ -16769,8 +16769,8 @@ class PubServer(BaseHTTPRequestHandler): print('EX: _receiveNewPostProcess ' + 'unable to delete ' + cachedFilename) # remove from memory cache - removePostFromCache(post_json_object, - self.server.recent_posts_cache) + remove_post_from_cache(post_json_object, + self.server.recent_posts_cache) # change the blog post title post_json_object['object']['summary'] = \ fields['subject'] diff --git a/inbox.py b/inbox.py index e84edc6d7..f8441c758 100644 --- a/inbox.py +++ b/inbox.py @@ -45,7 +45,7 @@ from utils import isBlogPost from utils import removeAvatarFromCache from utils import isPublicPost from utils import get_cached_post_filename -from utils import removePostFromCache +from utils import remove_post_from_cache from utils import urlPermitted from utils import createInboxQueueDir from utils import getStatusNumber @@ -938,7 +938,7 @@ def _receiveUpdateToQuestion(recent_posts_cache: {}, message_json: {}, print('EX: _receiveUpdateToQuestion unable to delete ' + cachedPostFilename) # remove from memory cache - removePostFromCache(message_json, recent_posts_cache) + remove_post_from_cache(message_json, recent_posts_cache) def _receiveUpdate(recent_posts_cache: {}, session, base_dir: str, @@ -3010,7 +3010,7 @@ def _receiveQuestionVote(base_dir: str, nickname: str, domain: str, if not questionPostFilename: return - removePostFromCache(questionJson, recent_posts_cache) + remove_post_from_cache(questionJson, recent_posts_cache) # ensure that the cached post is removed if it exists, so # that it then will be recreated cachedPostFilename = \ diff --git a/like.py b/like.py index 005dbb092..ea6e1efb7 100644 --- a/like.py +++ b/like.py @@ -26,7 +26,7 @@ from utils import has_group_type from utils import local_actor_url from utils import load_json from utils import save_json -from utils import removePostFromCache +from utils import remove_post_from_cache from utils import get_cached_post_filename from posts import sendSignedJson from session import postJson @@ -424,7 +424,7 @@ def updateLikesCollection(recent_posts_cache: {}, # remove any cached version of this post so that the # like icon is changed - removePostFromCache(post_json_object, recent_posts_cache) + remove_post_from_cache(post_json_object, recent_posts_cache) cachedPostFilename = \ get_cached_post_filename(base_dir, nickname, domain, post_json_object) diff --git a/reaction.py b/reaction.py index 20f22644e..598ea3a55 100644 --- a/reaction.py +++ b/reaction.py @@ -28,7 +28,7 @@ from utils import has_group_type from utils import local_actor_url from utils import load_json from utils import save_json -from utils import removePostFromCache +from utils import remove_post_from_cache from utils import get_cached_post_filename from utils import containsInvalidChars from posts import sendSignedJson @@ -454,7 +454,7 @@ def updateReactionCollection(recent_posts_cache: {}, # remove any cached version of this post so that the # reaction icon is changed - removePostFromCache(post_json_object, recent_posts_cache) + remove_post_from_cache(post_json_object, recent_posts_cache) cachedPostFilename = \ get_cached_post_filename(base_dir, nickname, domain, post_json_object) diff --git a/utils.py b/utils.py index c32535561..8f3c723cc 100644 --- a/utils.py +++ b/utils.py @@ -1567,7 +1567,8 @@ def _isBookmarked(base_dir: str, nickname: str, domain: str, return False -def removePostFromCache(post_json_object: {}, recent_posts_cache: {}) -> None: +def remove_post_from_cache(post_json_object: {}, + recent_posts_cache: {}) -> None: """ if the post exists in the recent posts cache then remove it """ if not recent_posts_cache: @@ -1603,16 +1604,16 @@ def _deleteCachedHtml(base_dir: str, nickname: str, domain: str, post_json_object: {}): """Removes cached html file for the given post """ - cachedPostFilename = \ + cached_post_filename = \ get_cached_post_filename(base_dir, nickname, domain, post_json_object) - if cachedPostFilename: - if os.path.isfile(cachedPostFilename): + if cached_post_filename: + if os.path.isfile(cached_post_filename): try: - os.remove(cachedPostFilename) + os.remove(cached_post_filename) except OSError: print('EX: _deleteCachedHtml ' + 'unable to delete cached post file ' + - str(cachedPostFilename)) + str(cached_post_filename)) def _deleteHashtagsOnPost(base_dir: str, post_json_object: {}) -> None: @@ -1741,7 +1742,7 @@ def deletePost(base_dir: str, http_prefix: str, return # remove from recent posts cache in memory - removePostFromCache(post_json_object, recent_posts_cache) + remove_post_from_cache(post_json_object, recent_posts_cache) # remove from conversation index _deleteConversationPost(base_dir, nickname, domain, post_json_object) @@ -2004,8 +2005,8 @@ def get_cached_post_filename(base_dir: str, nickname: str, domain: str, # print('ERROR: invalid html cache directory ' + cachedPostDir) return None cachedPostId = removeIdEnding(post_json_object['id']) - cachedPostFilename = cachedPostDir + '/' + cachedPostId.replace('/', '#') - return cachedPostFilename + '.html' + cached_post_filename = cachedPostDir + '/' + cachedPostId.replace('/', '#') + return cached_post_filename + '.html' def updateRecentPostsCache(recent_posts_cache: {}, max_recent_posts: int, @@ -2221,18 +2222,18 @@ def undoLikesCollectionEntry(recent_posts_cache: {}, # remove any cached version of this post so that the # like icon is changed nickname = getNicknameFromActor(actor) - cachedPostFilename = \ + cached_post_filename = \ get_cached_post_filename(base_dir, nickname, domain, post_json_object) - if cachedPostFilename: - if os.path.isfile(cachedPostFilename): + if cached_post_filename: + if os.path.isfile(cached_post_filename): try: - os.remove(cachedPostFilename) + os.remove(cached_post_filename) except OSError: print('EX: undoLikesCollectionEntry ' + 'unable to delete cached post ' + - str(cachedPostFilename)) - removePostFromCache(post_json_object, recent_posts_cache) + str(cached_post_filename)) + remove_post_from_cache(post_json_object, recent_posts_cache) if not post_json_object.get('type'): return @@ -2287,18 +2288,18 @@ def undoReactionCollectionEntry(recent_posts_cache: {}, # remove any cached version of this post so that the # like icon is changed nickname = getNicknameFromActor(actor) - cachedPostFilename = \ + cached_post_filename = \ get_cached_post_filename(base_dir, nickname, domain, post_json_object) - if cachedPostFilename: - if os.path.isfile(cachedPostFilename): + if cached_post_filename: + if os.path.isfile(cached_post_filename): try: - os.remove(cachedPostFilename) + os.remove(cached_post_filename) except OSError: print('EX: undoReactionCollectionEntry ' + 'unable to delete cached post ' + - str(cachedPostFilename)) - removePostFromCache(post_json_object, recent_posts_cache) + str(cached_post_filename)) + remove_post_from_cache(post_json_object, recent_posts_cache) if not post_json_object.get('type'): return @@ -2354,19 +2355,19 @@ def undo_announce_collection_entry(recent_posts_cache: {}, # remove any cached version of this announce so that the announce # icon is changed nickname = getNicknameFromActor(actor) - cachedPostFilename = \ + cached_post_filename = \ get_cached_post_filename(base_dir, nickname, domain, post_json_object) - if cachedPostFilename: - if os.path.isfile(cachedPostFilename): + if cached_post_filename: + if os.path.isfile(cached_post_filename): try: - os.remove(cachedPostFilename) + os.remove(cached_post_filename) except OSError: if debug: print('EX: undo_announce_collection_entry ' + 'unable to delete cached post ' + - str(cachedPostFilename)) - removePostFromCache(post_json_object, recent_posts_cache) + str(cached_post_filename)) + remove_post_from_cache(post_json_object, recent_posts_cache) if not post_json_object.get('type'): return @@ -2422,19 +2423,19 @@ def update_announce_collection(recent_posts_cache: {}, return # remove any cached version of this announce so that the announce # icon is changed - cachedPostFilename = \ + cached_post_filename = \ get_cached_post_filename(base_dir, nickname, domain, post_json_object) - if cachedPostFilename: - if os.path.isfile(cachedPostFilename): + if cached_post_filename: + if os.path.isfile(cached_post_filename): try: - os.remove(cachedPostFilename) + os.remove(cached_post_filename) except OSError: if debug: print('EX: update_announce_collection ' + 'unable to delete cached post ' + - str(cachedPostFilename)) - removePostFromCache(post_json_object, recent_posts_cache) + str(cached_post_filename)) + remove_post_from_cache(post_json_object, recent_posts_cache) if not has_object_dict(post_json_object): if debug: