merge-requests/30/head
Bob Mottram 2022-11-28 13:38:22 +00:00
parent 8eeae6968b
commit aa664c265e
1 changed files with 17 additions and 15 deletions

View File

@ -193,6 +193,7 @@ def update_moved_actors(base_dir: str, debug: bool) -> None:
if debug: if debug:
print('Updating moved actors') print('Updating moved actors')
actors_dict = {} actors_dict = {}
ctr = 0
for _, _, files in os.walk(actors_cache_dir): for _, _, files in os.walk(actors_cache_dir):
for actor_str in files: for actor_str in files:
if not actor_str.endswith('.json'): if not actor_str.endswith('.json'):
@ -204,13 +205,13 @@ def update_moved_actors(base_dir: str, debug: bool) -> None:
domain_full = get_full_domain(domain, port) domain_full = get_full_domain(domain, port)
handle = nickname + '@' + domain_full handle = nickname + '@' + domain_full
actors_dict[handle] = orig_str actors_dict[handle] = orig_str
ctr += 1
break break
if debug: if actors_dict:
if actors_dict: print('Actors dict created ' + str(ctr))
print('Actors dict created') else:
else: print('No cached actors found')
print('No cached actors found')
# get the handles to be checked for movedTo attribute # get the handles to be checked for movedTo attribute
handles_to_check = [] handles_to_check = []
@ -236,13 +237,14 @@ def update_moved_actors(base_dir: str, debug: bool) -> None:
handles_to_check.append(handle) handles_to_check.append(handle)
break break
if debug: if handles_to_check:
if handles_to_check: print('All accounts handles list generated ' +
print('All accounts handles list generated') str(len(handles_to_check)))
else: else:
print('No accounts are following') print('No accounts are following')
moved_str = '' moved_str = ''
ctr = 0
for handle in handles_to_check: for handle in handles_to_check:
if not actors_dict.get(handle): if not actors_dict.get(handle):
continue continue
@ -255,12 +257,12 @@ def update_moved_actors(base_dir: str, debug: bool) -> None:
if not actor_json.get('movedTo'): if not actor_json.get('movedTo'):
continue continue
moved_str += handle + ' ' + actor_json['movedTo'] + '\n' moved_str += handle + ' ' + actor_json['movedTo'] + '\n'
ctr = ctr + 1
if debug: if moved_str:
if moved_str: print('Moved accounts detected ' + str(ctr))
print('Moved accounts detected') else:
else: print('No moved accounts detected')
print('No moved accounts detected')
moved_accounts_filename = base_dir + '/accounts/actors_moved.txt' moved_accounts_filename = base_dir + '/accounts/actors_moved.txt'
if not moved_str: if not moved_str: