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,7 +1914,8 @@ def createSharedInboxIndex(baseDir: str,sharedBoxDir: str,postsInBoxDict: {},pos
handle=nickname+'@'+domain
followingFilename=baseDir+'/accounts/'+handle+'/following.txt'
postsInSharedInbox=os.scandir(sharedBoxDir)
for postFilename in postsInSharedInbox:
followingHandles=None
for postFilename in postsInSharedInbox:
postFilename=postFilename.name
if not postFilename.endswith('.json'):
continue
@ -1943,9 +1944,12 @@ def createSharedInboxIndex(baseDir: str,sharedBoxDir: str,postsInBoxDict: {},pos
actorDomain,actorPort=getDomainFromActor(postJsonObject['actor'])
if not (actorNickname and actorDomain):
continue
# 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
if ocapAlways: