Only load the following handles once

main2
Bob Mottram 2019-10-20 10:47:06 +01:00
parent ab85b2ea16
commit f3c4baadb1
1 changed files with 7 additions and 3 deletions

View File

@ -1914,6 +1914,7 @@ def createSharedInboxIndex(baseDir: str,sharedBoxDir: str,postsInBoxDict: {},pos
handle=nickname+'@'+domain handle=nickname+'@'+domain
followingFilename=baseDir+'/accounts/'+handle+'/following.txt' followingFilename=baseDir+'/accounts/'+handle+'/following.txt'
postsInSharedInbox=os.scandir(sharedBoxDir) postsInSharedInbox=os.scandir(sharedBoxDir)
followingHandles=None
for postFilename in postsInSharedInbox: for postFilename in postsInSharedInbox:
postFilename=postFilename.name postFilename=postFilename.name
if not postFilename.endswith('.json'): if not postFilename.endswith('.json'):
@ -1945,7 +1946,10 @@ def createSharedInboxIndex(baseDir: str,sharedBoxDir: str,postsInBoxDict: {},pos
continue continue
# is the actor followed by this account? # is the actor followed by this account?
if not (actorNickname+'@'+actorDomain in open(followingFilename).read()): if not followingHandles:
with open(followingFilename, 'r') as followingFile:
followingHandles = followingFile.read()
if actorNickname+'@'+actorDomain not in followingHandles:
continue continue
if ocapAlways: if ocapAlways: