Archive the index file

main2
Bob Mottram 2019-10-20 12:18:25 +01:00
parent 3025922d5c
commit 079c5003f6
1 changed files with 20 additions and 0 deletions

View File

@ -2211,6 +2211,26 @@ def archivePostsForPerson(httpPrefix: str,nickname: str,domain: str,baseDir: str
if noOfPosts<=maxPostsInBox: if noOfPosts<=maxPostsInBox:
return 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={} postsInBoxDict={}
postsCtr=0 postsCtr=0
for postFilename in postsInBox: for postFilename in postsInBox: