Use index to construct timeline

main2
Bob Mottram 2019-10-20 12:40:35 +01:00
parent 8f826a1ac5
commit 7e0ae8d8e1
1 changed files with 25 additions and 9 deletions

View File

@ -2029,17 +2029,33 @@ def createBoxBase(session,baseDir: str,boxname: str, \
# post filenames sorted in descending order
postsInBoxDict={}
postsCtr=createBoxIndex(boxDir,postsInBoxDict)
# combine the inbox for the account with the shared inbox
if sharedBoxDir:
postsCtr= \
createSharedInboxIndex(baseDir,sharedBoxDir, \
postsInBoxDict,postsCtr, \
nickname,domain,ocapAlways)
indexFilename=baseDir+'/accounts/'+nickname+'@'+domain+'/'+boxname+'.index'
if os.path.isfile(indexFilename):
print('DEBUG: using index file to construct timeline')
postsCtr=0
maxPostCtr=None
if pageNumber:
maxPostCtr=itemsPerPage*pageNumber
with open(indexFilename, 'r') as indexFile:
for postFilename in indexFile:
postsInBoxDict[postsCtr]=os.path.join(boxDir, postFilename)
postsCtr+=1
if maxPostCtr:
if postsCtr>=maxPostCtr:
break
else:
postsCtr=createBoxIndex(boxDir,postsInBoxDict)
# sort the list in descending order of date
postsInBox=OrderedDict(sorted(postsInBoxDict.items(),reverse=True))
# combine the inbox for the account with the shared inbox
if sharedBoxDir:
postsCtr= \
createSharedInboxIndex(baseDir,sharedBoxDir, \
postsInBoxDict,postsCtr, \
nickname,domain,ocapAlways)
# sort the list in descending order of date
postsInBox=OrderedDict(sorted(postsInBoxDict.items(),reverse=True))
# number of posts in box
boxHeader['totalItems']=postsCtr