Don't use cache for public only posts

main2
Bob Mottram 2019-10-19 11:34:06 +01:00
parent 4d349544ed
commit 966baef1cd
1 changed files with 19 additions and 18 deletions

View File

@ -1728,24 +1728,25 @@ def individualPostAsHtml(iconsDir: str,translate: {}, \
showPublicOnly=False) -> str: showPublicOnly=False) -> str:
""" Shows a single post as html """ Shows a single post as html
""" """
# if a cached version of the post already exists then fetch it if not showPublicOnly:
htmlPostCacheDir=baseDir+'/accounts/'+nickname+'@'+domain+'/postcache' # if a cached version of the post already exists then fetch it
cachedPostFilename=htmlPostCacheDir+'/'+postJsonObject['id'].replace('/activity','').replace('/','#')+'.html' htmlPostCacheDir=baseDir+'/accounts/'+nickname+'@'+domain+'/postcache'
if os.path.isfile(cachedPostFilename): cachedPostFilename=htmlPostCacheDir+'/'+postJsonObject['id'].replace('/activity','').replace('/','#')+'.html'
postStr='' if os.path.isfile(cachedPostFilename):
tries=0 postStr=''
while tries<3: tries=0
try: while tries<3:
with open(cachedPostFilename, 'r') as file: try:
postStr = file.read() with open(cachedPostFilename, 'r') as file:
break postStr = file.read()
except Exception as e: break
print(e) except Exception as e:
# no sleep print(e)
tries+=1 # no sleep
if postStr: tries+=1
return postStr if postStr:
return postStr
# If this is the inbox timeline then don't show the repeat icon on any DMs # If this is the inbox timeline then don't show the repeat icon on any DMs
showRepeatIcon=showRepeats showRepeatIcon=showRepeats
showDMicon=False showDMicon=False