Check for invalid directory

main
Bob Mottram 2019-11-29 23:04:37 +00:00
parent aa8956827d
commit 8dc02ae340
5 changed files with 29 additions and 13 deletions

View File

@ -88,6 +88,7 @@ def undoAnnounceCollectionEntry(recentPostsCache: {}, \
nickname=getNicknameFromActor(actor)
cachedPostFilename= \
getCachedPostFilename(baseDir,nickname,domain,postJsonObject)
if cachedPostFilename:
if os.path.isfile(cachedPostFilename):
os.remove(cachedPostFilename)
removePostFromCache(postJsonObject,recentPostsCache)
@ -144,6 +145,7 @@ def updateAnnounceCollection(recentPostsCache: {}, \
nickname=getNicknameFromActor(actor)
cachedPostFilename= \
getCachedPostFilename(baseDir,nickname,domain,postJsonObject)
if cachedPostFilename:
if os.path.isfile(cachedPostFilename):
os.remove(cachedPostFilename)
removePostFromCache(postJsonObject,recentPostsCache)

View File

@ -37,6 +37,7 @@ def undoBookmarksCollectionEntry(recentPostsCache: {}, \
nickname=getNicknameFromActor(actor)
cachedPostFilename= \
getCachedPostFilename(baseDir,nickname,domain,postJsonObject)
if cachedPostFilename:
if os.path.isfile(cachedPostFilename):
os.remove(cachedPostFilename)
removePostFromCache(postJsonObject,recentPostsCache)
@ -143,6 +144,7 @@ def updateBookmarksCollection(recentPostsCache: {}, \
nickname=getNicknameFromActor(actor)
cachedPostFilename= \
getCachedPostFilename(baseDir,nickname,domain,postJsonObject)
if cachedPostFilename:
if os.path.isfile(cachedPostFilename):
os.remove(cachedPostFilename)
removePostFromCache(postJsonObject,recentPostsCache)

View File

@ -35,6 +35,7 @@ def undoLikesCollectionEntry(recentPostsCache: {}, \
nickname=getNicknameFromActor(actor)
cachedPostFilename= \
getCachedPostFilename(baseDir,nickname,domain,postJsonObject)
if cachedPostFilename:
if os.path.isfile(cachedPostFilename):
os.remove(cachedPostFilename)
removePostFromCache(postJsonObject,recentPostsCache)
@ -117,6 +118,7 @@ def updateLikesCollection(recentPostsCache: {}, \
nickname=getNicknameFromActor(actor)
cachedPostFilename= \
getCachedPostFilename(baseDir,nickname,domain,postJsonObject)
if cachedPostFilename:
if os.path.isfile(cachedPostFilename):
os.remove(cachedPostFilename)
removePostFromCache(postJsonObject,recentPostsCache)

View File

@ -447,8 +447,15 @@ def getCachedPostFilename(baseDir: str,nickname: str,domain: str, \
postJsonObject: {}) -> str:
"""Returns the html cache filename for the given post
"""
cachedPostDir=getCachedPostDirectory(baseDir,nickname,domain)
if not os.path.isdir(cachedPostDir):
print('ERROR: invalid html cache directory '+cachedPostDir)
return None
if '@' not in cachedPostDir:
print('ERROR: invalid html cache directory '+cachedPostDir)
return None
cachedPostFilename= \
getCachedPostDirectory(baseDir,nickname,domain)+ \
cachedPostDir+ \
'/'+postJsonObject['id'].replace('/activity','')
print('CACHE: 1 '+nickname+' '+domain+' '+cachedPostFilename)
if '#' in cachedPostFilename:

View File

@ -1948,6 +1948,9 @@ def loadIndividualPostAsHtmlFromCache(baseDir: str,nickname: str,domain: str, \
cachedPostFilename=getCachedPostFilename(baseDir,nickname,domain,postJsonObject)
postHtml=''
if not cachedPostFilename:
return postHtml
if not os.path.isfile(cachedPostFilename):
return postHtml