Exception handling

main
bashrc 2026-01-15 13:55:15 +00:00
parent 724ffb7dff
commit 9cc8a2fb00
1 changed files with 16 additions and 5 deletions

View File

@ -5829,15 +5829,26 @@ def archive_posts_for_person(http_prefix: str, nickname: str, domain: str,
for ext in extensions: for ext in extensions:
ext_path = file_path.replace('.json', '.' + ext) ext_path = file_path.replace('.json', '.' + ext)
if os.path.isfile(ext_path): if os.path.isfile(ext_path):
try:
os.rename(ext_path, os.rename(ext_path,
archive_path.replace('.json', '.' + ext)) archive_path.replace('.json', '.' + ext))
else: except OSError:
ext_path = file_path.replace('.json', print('EX: unable to archive file ' + ext_path +
'.json.' + ext) ' -> ' +
archive_path.replace('.json', '.' + ext))
continue
ext_path = file_path.replace('.json', '.json.' + ext)
if os.path.isfile(ext_path): if os.path.isfile(ext_path):
try:
os.rename(ext_path, os.rename(ext_path,
archive_path.replace('.json', archive_path.replace('.json',
'.json.' + ext)) '.json.' + ext))
except OSError:
print('EX: unable to archive file ' + ext_path +
' -> ' +
archive_path.replace('.json',
'.json.' + ext))
else: else:
delete_post(base_dir, http_prefix, nickname, domain, delete_post(base_dir, http_prefix, nickname, domain,
file_path, False, recent_posts_cache, False) file_path, False, recent_posts_cache, False)