mirror of https://gitlab.com/bashrc2/epicyon
Remove redundant function
parent
3a509400a7
commit
607f54eb5b
43
utils.py
43
utils.py
|
@ -1265,14 +1265,24 @@ def _isBookmarked(baseDir: str, nickname: str, domain: str,
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def _deleteFromRecentPosts(postJsonObject: {}, recentPostsCache: {}) -> None:
|
def removePostFromCache(postJsonObject: {}, recentPostsCache: {}) -> None:
|
||||||
"""Remove the given post from the recent posts cache
|
""" if the post exists in the recent posts cache then remove it
|
||||||
"""
|
"""
|
||||||
if not recentPostsCache:
|
if not recentPostsCache:
|
||||||
return
|
return
|
||||||
|
|
||||||
postId = \
|
if not postJsonObject.get('id'):
|
||||||
removeIdEnding(postJsonObject['id']).replace('/', '#')
|
return
|
||||||
|
|
||||||
|
if not recentPostsCache.get('index'):
|
||||||
|
return
|
||||||
|
|
||||||
|
postId = postJsonObject['id']
|
||||||
|
if '#' in postId:
|
||||||
|
postId = postId.split('#', 1)[0]
|
||||||
|
postId = removeIdEnding(postId).replace('/', '#')
|
||||||
|
if postId not in recentPostsCache['index']:
|
||||||
|
return
|
||||||
|
|
||||||
if recentPostsCache.get('index'):
|
if recentPostsCache.get('index'):
|
||||||
if postId in recentPostsCache['index']:
|
if postId in recentPostsCache['index']:
|
||||||
|
@ -1371,7 +1381,7 @@ def deletePost(baseDir: str, httpPrefix: str,
|
||||||
return
|
return
|
||||||
|
|
||||||
# remove from recent posts cache in memory
|
# remove from recent posts cache in memory
|
||||||
_deleteFromRecentPosts(postJsonObject, recentPostsCache)
|
removePostFromCache(postJsonObject, recentPostsCache)
|
||||||
|
|
||||||
# remove any attachment
|
# remove any attachment
|
||||||
_removeAttachment(baseDir, httpPrefix, domain, postJsonObject)
|
_removeAttachment(baseDir, httpPrefix, domain, postJsonObject)
|
||||||
|
@ -1607,29 +1617,6 @@ def getCachedPostFilename(baseDir: str, nickname: str, domain: str,
|
||||||
return cachedPostFilename + '.html'
|
return cachedPostFilename + '.html'
|
||||||
|
|
||||||
|
|
||||||
def removePostFromCache(postJsonObject: {}, recentPostsCache: {}):
|
|
||||||
""" if the post exists in the recent posts cache then remove it
|
|
||||||
"""
|
|
||||||
if not postJsonObject.get('id'):
|
|
||||||
return
|
|
||||||
|
|
||||||
if not recentPostsCache.get('index'):
|
|
||||||
return
|
|
||||||
|
|
||||||
postId = postJsonObject['id']
|
|
||||||
if '#' in postId:
|
|
||||||
postId = postId.split('#', 1)[0]
|
|
||||||
postId = removeIdEnding(postId).replace('/', '#')
|
|
||||||
if postId not in recentPostsCache['index']:
|
|
||||||
return
|
|
||||||
|
|
||||||
if recentPostsCache['json'].get(postId):
|
|
||||||
del recentPostsCache['json'][postId]
|
|
||||||
if recentPostsCache['html'].get(postId):
|
|
||||||
del recentPostsCache['html'][postId]
|
|
||||||
recentPostsCache['index'].remove(postId)
|
|
||||||
|
|
||||||
|
|
||||||
def updateRecentPostsCache(recentPostsCache: {}, maxRecentPosts: int,
|
def updateRecentPostsCache(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
postJsonObject: {}, htmlStr: str) -> None:
|
postJsonObject: {}, htmlStr: str) -> None:
|
||||||
"""Store recent posts in memory so that they can be quickly recalled
|
"""Store recent posts in memory so that they can be quickly recalled
|
||||||
|
|
Loading…
Reference in New Issue