Remove cached avatar image after actor update

main2
Bob Mottram 2019-09-14 19:58:55 +01:00
parent 76c31b463e
commit e18fe78b9c
1 changed files with 22 additions and 5 deletions

View File

@ -613,6 +613,8 @@ def personReceiveUpdate(baseDir: str, \
if updatePort!=80 and updatePort!=443:
updateDomainFull=updateDomain+':'+str(updatePort)
actor=updateDomainFull+'/users/'+updateNickname
if actor not in personJson['id']:
actor=updateDomainFull+'/profile/'+updateNickname
if actor not in personJson['id']:
if debug:
print('actor: '+actor)
@ -653,6 +655,21 @@ def personReceiveUpdate(baseDir: str, \
with open(actorFilename, 'w') as fp:
commentjson.dump(personJson, fp, indent=4, sort_keys=False)
print('actor updated for '+personJson['id'])
# remove avatar if it exists so that it will be refreshed later
# when a timeline is constructed
actorStr=personJson['id'].replace('/','-')
avatarFilename=baseDir+'/cache/avatars/'+actorStr+'.png'
if os.path.isfile(avatarFilename):
os.remove(avatarFilename)
else:
avatarFilename=baseDir+'/cache/avatars/'+actorStr+'.jpg'
if os.path.isfile(avatarFilename):
os.remove(avatarFilename)
else:
avatarFilename=baseDir+'/cache/avatars/'+actorStr+'.gif'
if os.path.isfile(avatarFilename):
os.remove(avatarFilename)
return True
def receiveUpdate(session,baseDir: str, \