From a17e2b1ad29ca3c897ae8b46336b819bb2e78c26 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 24 Jun 2020 15:11:10 +0100 Subject: [PATCH] Check if index exists --- utils.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/utils.py b/utils.py index 76e66b3d6..c9c9b1d1d 100644 --- a/utils.py +++ b/utils.py @@ -464,12 +464,14 @@ def deletePost(baseDir: str, httpPrefix: str, return # remove from recent posts cache in memory - postId = \ - postJsonObject['id'].replace('/activity', '').replace('/', '#') - if postId in recentPostsCache['index']: - recentPostsCache['index'].remove(postId) - if recentPostsCache['json'].get(postId): - del recentPostsCache['json'][postId] + if recentPostsCache: + postId = \ + postJsonObject['id'].replace('/activity', '').replace('/', '#') + if recentPostsCache.get('index'): + if postId in recentPostsCache['index']: + recentPostsCache['index'].remove(postId) + if recentPostsCache['json'].get(postId): + del recentPostsCache['json'][postId] # remove any attachment removeAttachment(baseDir, httpPrefix, domain, postJsonObject)