From 20dd5e069a65c3c905b3bd5c485889754d035702 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 18 Oct 2020 17:19:28 +0100 Subject: [PATCH] Clear post from caches before updating --- newsdaemon.py | 2 ++ utils.py | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/newsdaemon.py b/newsdaemon.py index e8c41da09..b7a14d130 100644 --- a/newsdaemon.py +++ b/newsdaemon.py @@ -25,6 +25,7 @@ from content import validHashTag from utils import loadJson from utils import saveJson from utils import getStatusNumber +from utils import clearFromPostCaches from inbox import storeHashTags @@ -490,6 +491,7 @@ def convertRSStoActivityPub(baseDir: str, httpPrefix: str, storeHashTags(baseDir, 'news', blog) + clearFromPostCaches(baseDir, postId) if saveJson(blog, filename): updateFeedsOutboxIndex(baseDir, domain, postId + '.json') diff --git a/utils.py b/utils.py index 6ed6c1c62..d0ced0b32 100644 --- a/utils.py +++ b/utils.py @@ -587,6 +587,26 @@ def locateNewsArrival(baseDir: str, domain: str, return None +def clearFromPostCaches(baseDir: str, postId: str) -> None: + """Clears cached html for the given post, so that edits + to news will appear + """ + filename = postId + '.html' + for subdir, dirs, files in os.walk(baseDir + '/accounts'): + for acct in dirs: + if '@' not in acct: + continue + if 'inbox@' in acct: + continue + cacheDir = os.path.join(baseDir + '/accounts/postcache', acct) + postFilename = cacheDir + filename + if os.path.isfile(postFilename): + try: + os.remove(postFilename) + except BaseException: + pass + + def locatePost(baseDir: str, nickname: str, domain: str, postUrl: str, replies=False) -> str: """Returns the filename for the given status post url