Allow actor with updated attachments to be written to the cache

main
Bob Mottram 2023-08-23 12:17:25 +01:00
parent 3784ab53f8
commit c7ec441e90
2 changed files with 11 additions and 7 deletions

View File

@ -18,8 +18,8 @@ from utils import get_file_case_insensitive
from utils import get_user_paths
def _remove_person_from_cache(base_dir: str, person_url: str,
person_cache: {}) -> bool:
def remove_person_from_cache(base_dir: str, person_url: str,
person_cache: {}) -> bool:
"""Removes an actor from the cache
"""
cache_filename = base_dir + '/cache/actors/' + \
@ -53,8 +53,8 @@ def clear_actor_cache(base_dir: str, person_cache: {},
if clear_domain not in fname:
continue
person_url = fname.replace('#', '/').replace('.json', '')
_remove_person_from_cache(base_dir, person_url,
person_cache)
remove_person_from_cache(base_dir, person_url,
person_cache)
break
@ -73,7 +73,7 @@ def check_for_changed_actor(session, base_dir: str,
return
if url_exists(session, avatar_url, timeout_sec, http_prefix, domain_full):
return
_remove_person_from_cache(base_dir, person_url, person_cache)
remove_person_from_cache(base_dir, person_url, person_cache)
def store_person_in_cache(base_dir: str, person_url: str,

View File

@ -386,6 +386,7 @@ from content import add_html_tags
from content import extract_media_in_form_post
from content import save_media_in_form_post
from content import extract_text_fields_in_post
from cache import remove_person_from_cache
from cache import clear_actor_cache
from cache import get_actor_public_key_from_id
from cache import check_for_changed_actor
@ -5285,8 +5286,9 @@ class PubServer(BaseHTTPRequestHandler):
share_nickname, share_domain,
actor_json,
self.server.max_shares_on_profile):
remove_person_from_cache(base_dir, actor, person_cache)
store_person_in_cache(base_dir, actor,
actor_json, person_cache, False)
actor_json, person_cache, True)
actor_filename = acct_dir(base_dir, share_nickname,
share_domain) + '.json'
save_json(actor_json, actor_filename)
@ -22568,8 +22570,10 @@ class PubServer(BaseHTTPRequestHandler):
nickname, self.server.domain,
actor_json,
self.server.max_shares_on_profile):
remove_person_from_cache(self.server.base_dir, actor,
person_cache)
store_person_in_cache(self.server.base_dir, actor,
actor_json, person_cache, False)
actor_json, person_cache, True)
actor_filename = acct_dir(self.server.base_dir,
nickname,
self.server.domain) + '.json'