forked from indymedia/epicyon
Down download avatars at the same time as displaying the timeline
parent
c83efd2a18
commit
9fab236f04
|
@ -199,7 +199,8 @@ def setBlogAddress(actorJson: {}, blogAddress: str) -> None:
|
||||||
|
|
||||||
def updateAvatarImageCache(session, baseDir: str, httpPrefix: str,
|
def updateAvatarImageCache(session, baseDir: str, httpPrefix: str,
|
||||||
actor: str, avatarUrl: str,
|
actor: str, avatarUrl: str,
|
||||||
personCache: {}, force=False) -> str:
|
personCache: {}, allowDownloads: bool,
|
||||||
|
force=False) -> str:
|
||||||
"""Updates the cached avatar for the given actor
|
"""Updates the cached avatar for the given actor
|
||||||
"""
|
"""
|
||||||
if not avatarUrl:
|
if not avatarUrl:
|
||||||
|
@ -232,7 +233,7 @@ def updateAvatarImageCache(session, baseDir: str, httpPrefix: str,
|
||||||
avatarImageFilename = avatarImagePath + '.webp'
|
avatarImageFilename = avatarImagePath + '.webp'
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
if not os.path.isfile(avatarImageFilename) or force:
|
if (not os.path.isfile(avatarImageFilename) or force) and allowDownloads:
|
||||||
try:
|
try:
|
||||||
print('avatar image url: ' + avatarUrl)
|
print('avatar image url: ' + avatarUrl)
|
||||||
result = session.get(avatarUrl,
|
result = session.get(avatarUrl,
|
||||||
|
@ -283,7 +284,8 @@ def updateAvatarImageCache(session, baseDir: str, httpPrefix: str,
|
||||||
actor)
|
actor)
|
||||||
return None
|
return None
|
||||||
storePersonInCache(baseDir, actor, personJson, personCache)
|
storePersonInCache(baseDir, actor, personJson, personCache)
|
||||||
return getPersonAvatarUrl(baseDir, actor, personCache, True)
|
return getPersonAvatarUrl(baseDir, actor, personCache,
|
||||||
|
allowDownloads)
|
||||||
return None
|
return None
|
||||||
return avatarImageFilename.replace(baseDir + '/cache', '')
|
return avatarImageFilename.replace(baseDir + '/cache', '')
|
||||||
|
|
||||||
|
@ -3861,7 +3863,8 @@ def individualPostAsHtml(allowDownloads: bool,
|
||||||
print('TIMING INDIV ' + boxName + ' 2.1 = ' + str(timeDiff))
|
print('TIMING INDIV ' + boxName + ' 2.1 = ' + str(timeDiff))
|
||||||
|
|
||||||
updateAvatarImageCache(session, baseDir, httpPrefix,
|
updateAvatarImageCache(session, baseDir, httpPrefix,
|
||||||
postActor, avatarUrl, personCache)
|
postActor, avatarUrl, personCache,
|
||||||
|
allowDownloads)
|
||||||
|
|
||||||
# benchmark 2.2
|
# benchmark 2.2
|
||||||
timeDiff = int((time.time() - postStartTime) * 1000)
|
timeDiff = int((time.time() - postStartTime) * 1000)
|
||||||
|
@ -3892,10 +3895,12 @@ def individualPostAsHtml(allowDownloads: bool,
|
||||||
allowDownloads)
|
allowDownloads)
|
||||||
avatarUrl = \
|
avatarUrl = \
|
||||||
updateAvatarImageCache(session, baseDir, httpPrefix,
|
updateAvatarImageCache(session, baseDir, httpPrefix,
|
||||||
postActor, avatarUrl, personCache)
|
postActor, avatarUrl, personCache,
|
||||||
|
allowDownloads)
|
||||||
else:
|
else:
|
||||||
updateAvatarImageCache(session, baseDir, httpPrefix,
|
updateAvatarImageCache(session, baseDir, httpPrefix,
|
||||||
postActor, avatarUrl, personCache)
|
postActor, avatarUrl, personCache,
|
||||||
|
allowDownloads)
|
||||||
|
|
||||||
# benchmark 5
|
# benchmark 5
|
||||||
timeDiff = int((time.time() - postStartTime) * 1000)
|
timeDiff = int((time.time() - postStartTime) * 1000)
|
||||||
|
|
Loading…
Reference in New Issue