Remove cached posts during archive

main2
Bob Mottram 2019-10-19 11:10:52 +01:00
parent 455e0451c1
commit 451684fdca
1 changed files with 9 additions and 0 deletions

View File

@ -2192,6 +2192,9 @@ def archivePostsForPerson(httpPrefix: str,nickname: str,domain: str,baseDir: str
# sort the list in ascending order of date # sort the list in ascending order of date
postsInBox=OrderedDict(sorted(postsInBoxDict.items(),reverse=False)) postsInBox=OrderedDict(sorted(postsInBoxDict.items(),reverse=False))
# directory containing cached html posts
postCacheDir=boxDir.replace('/'+boxname,'/postcache')
for statusNumber,postFilename in postsInBox.items(): for statusNumber,postFilename in postsInBox.items():
filePath = os.path.join(boxDir, postFilename) filePath = os.path.join(boxDir, postFilename)
if not os.path.isfile(filePath): if not os.path.isfile(filePath):
@ -2204,6 +2207,12 @@ def archivePostsForPerson(httpPrefix: str,nickname: str,domain: str,baseDir: str
os.rename(repliesPath,archivePath) os.rename(repliesPath,archivePath)
else: else:
deletePost(baseDir,httpPrefix,nickname,domain,filePath,False) deletePost(baseDir,httpPrefix,nickname,domain,filePath,False)
# remove cached html posts
postCacheFilename=os.path.join(postCacheDir, postFilename).replace('.json','.html')
if os.path.isfile(postCacheFilename):
os.remove(postCacheFilename)
noOfPosts -= 1 noOfPosts -= 1
if noOfPosts <= maxPostsInBox: if noOfPosts <= maxPostsInBox:
break break