mirror of https://gitlab.com/bashrc2/epicyon
Move cache function
parent
a91666ccfb
commit
f5c427d8cc
19
cache.py
19
cache.py
|
@ -28,6 +28,7 @@ from utils import get_file_case_insensitive
|
||||||
from utils import get_user_paths
|
from utils import get_user_paths
|
||||||
from utils import date_utcnow
|
from utils import date_utcnow
|
||||||
from utils import date_from_string_format
|
from utils import date_from_string_format
|
||||||
|
from utils import get_image_extensions
|
||||||
from content import remove_script
|
from content import remove_script
|
||||||
|
|
||||||
|
|
||||||
|
@ -391,3 +392,21 @@ def update_recent_posts_cache(recent_posts_cache: {}, max_recent_posts: int,
|
||||||
recent_posts_cache['html'] = {}
|
recent_posts_cache['html'] = {}
|
||||||
recent_posts_cache['json'][post_id] = json.dumps(post_json_object)
|
recent_posts_cache['json'][post_id] = json.dumps(post_json_object)
|
||||||
recent_posts_cache['html'][post_id] = html_str
|
recent_posts_cache['html'][post_id] = html_str
|
||||||
|
|
||||||
|
|
||||||
|
def remove_avatar_from_cache(base_dir: str, actor_str: str) -> None:
|
||||||
|
"""Removes any existing avatar entries from the cache
|
||||||
|
This avoids duplicate entries with differing extensions
|
||||||
|
"""
|
||||||
|
avatar_filename_extensions = get_image_extensions()
|
||||||
|
for extension in avatar_filename_extensions:
|
||||||
|
avatar_filename = \
|
||||||
|
base_dir + '/cache/avatars/' + actor_str + '.' + extension
|
||||||
|
if not os.path.isfile(avatar_filename):
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
os.remove(avatar_filename)
|
||||||
|
except OSError:
|
||||||
|
print('EX: remove_avatar_from_cache ' +
|
||||||
|
'unable to delete cached avatar ' +
|
||||||
|
str(avatar_filename))
|
||||||
|
|
|
@ -22,7 +22,6 @@ from flags import is_memorial_account
|
||||||
from flags import is_premium_account
|
from flags import is_premium_account
|
||||||
from utils import data_dir
|
from utils import data_dir
|
||||||
from utils import set_premium_account
|
from utils import set_premium_account
|
||||||
from utils import remove_avatar_from_cache
|
|
||||||
from utils import save_json
|
from utils import save_json
|
||||||
from utils import save_reverse_timeline
|
from utils import save_reverse_timeline
|
||||||
from utils import set_minimize_all_images
|
from utils import set_minimize_all_images
|
||||||
|
@ -141,6 +140,7 @@ from shares import merge_shared_item_tokens
|
||||||
from roles import set_roles_from_list
|
from roles import set_roles_from_list
|
||||||
from schedule import remove_scheduled_posts
|
from schedule import remove_scheduled_posts
|
||||||
from cwlists import get_cw_list_variable
|
from cwlists import get_cw_list_variable
|
||||||
|
from cache import remove_avatar_from_cache
|
||||||
from cache import store_person_in_cache
|
from cache import store_person_in_cache
|
||||||
from daemon_utils import post_to_outbox
|
from daemon_utils import post_to_outbox
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,6 @@ from utils import get_actor_from_post
|
||||||
from utils import locate_post
|
from utils import locate_post
|
||||||
from utils import remove_id_ending
|
from utils import remove_id_ending
|
||||||
from utils import has_actor
|
from utils import has_actor
|
||||||
from utils import remove_avatar_from_cache
|
|
||||||
from utils import text_in_file
|
from utils import text_in_file
|
||||||
from utils import is_account_dir
|
from utils import is_account_dir
|
||||||
from utils import data_dir
|
from utils import data_dir
|
||||||
|
@ -53,6 +52,7 @@ from utils import get_url_from_post
|
||||||
from utils import remove_html
|
from utils import remove_html
|
||||||
from utils import get_full_domain
|
from utils import get_full_domain
|
||||||
from utils import get_user_paths
|
from utils import get_user_paths
|
||||||
|
from cache import remove_avatar_from_cache
|
||||||
from cache import get_person_from_cache
|
from cache import get_person_from_cache
|
||||||
from cache import get_actor_public_key_from_id
|
from cache import get_actor_public_key_from_id
|
||||||
from cache import store_person_in_cache
|
from cache import store_person_in_cache
|
||||||
|
|
18
utils.py
18
utils.py
|
@ -1066,24 +1066,6 @@ def get_link_prefixes() -> []:
|
||||||
'hyper://', 'gemini://', 'gopher://', 'briar:')
|
'hyper://', 'gemini://', 'gopher://', 'briar:')
|
||||||
|
|
||||||
|
|
||||||
def remove_avatar_from_cache(base_dir: str, actor_str: str) -> None:
|
|
||||||
"""Removes any existing avatar entries from the cache
|
|
||||||
This avoids duplicate entries with differing extensions
|
|
||||||
"""
|
|
||||||
avatar_filename_extensions = get_image_extensions()
|
|
||||||
for extension in avatar_filename_extensions:
|
|
||||||
avatar_filename = \
|
|
||||||
base_dir + '/cache/avatars/' + actor_str + '.' + extension
|
|
||||||
if not os.path.isfile(avatar_filename):
|
|
||||||
continue
|
|
||||||
try:
|
|
||||||
os.remove(avatar_filename)
|
|
||||||
except OSError:
|
|
||||||
print('EX: remove_avatar_from_cache ' +
|
|
||||||
'unable to delete cached avatar ' +
|
|
||||||
str(avatar_filename))
|
|
||||||
|
|
||||||
|
|
||||||
def save_json(json_object: {}, filename: str) -> bool:
|
def save_json(json_object: {}, filename: str) -> bool:
|
||||||
"""Saves json to a file
|
"""Saves json to a file
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue