Clear post from caches before updating

main
Bob Mottram 2020-10-18 17:19:28 +01:00
parent 2132b01950
commit 20dd5e069a
2 changed files with 22 additions and 0 deletions

View File

@ -25,6 +25,7 @@ from content import validHashTag
from utils import loadJson from utils import loadJson
from utils import saveJson from utils import saveJson
from utils import getStatusNumber from utils import getStatusNumber
from utils import clearFromPostCaches
from inbox import storeHashTags from inbox import storeHashTags
@ -490,6 +491,7 @@ def convertRSStoActivityPub(baseDir: str, httpPrefix: str,
storeHashTags(baseDir, 'news', blog) storeHashTags(baseDir, 'news', blog)
clearFromPostCaches(baseDir, postId)
if saveJson(blog, filename): if saveJson(blog, filename):
updateFeedsOutboxIndex(baseDir, domain, postId + '.json') updateFeedsOutboxIndex(baseDir, domain, postId + '.json')

View File

@ -587,6 +587,26 @@ def locateNewsArrival(baseDir: str, domain: str,
return None 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, def locatePost(baseDir: str, nickname: str, domain: str,
postUrl: str, replies=False) -> str: postUrl: str, replies=False) -> str:
"""Returns the filename for the given status post url """Returns the filename for the given status post url