From 079c5003f6da16e76737e5367b9de2cda00ac0f9 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 20 Oct 2019 12:18:25 +0100 Subject: [PATCH] Archive the index file --- posts.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/posts.py b/posts.py index c763920e..65c430fa 100644 --- a/posts.py +++ b/posts.py @@ -2211,6 +2211,26 @@ def archivePostsForPerson(httpPrefix: str,nickname: str,domain: str,baseDir: str if noOfPosts<=maxPostsInBox: return + # remove entries from the index + handle=nickname+'@'+domain + indexFilename=baseDir+'/accounts/'+handle+'/'+boxname+'.index' + if os.path.isfile(indexFilename): + indexCtr=0 + # get the existing index entries as a string + newIndex='' + with open(indexFilename, 'r') as indexFile: + for postId in indexFile: + newIndex+=postId + indexCtr+=1 + if indexCtr>=maxPostsInBox: + break + # save the new index file + if len(newIndex)>0: + indexFile=open(indexFilename,'w+') + if indexFile: + indexFile.write(newIndex) + indexFile.close() + postsInBoxDict={} postsCtr=0 for postFilename in postsInBox: