From fb088adcbea2c86f7eb7942b269520ee03a07232 Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@libreserver.org>
Date: Mon, 6 Feb 2023 11:47:24 +0000
Subject: [PATCH] Tidying

---
 inbox.py       |  1 +
 webapp_post.py | 12 ++++++++----
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/inbox.py b/inbox.py
index b43c2d412..68e821ea6 100644
--- a/inbox.py
+++ b/inbox.py
@@ -2701,6 +2701,7 @@ def _receive_announce(recent_posts_cache: {},
             print('DEBUG: announce post not found in inbox or outbox')
             print(message_json['object'])
         return True
+    # add actor to the list of announcers for a post
     update_announce_collection(recent_posts_cache, base_dir, post_filename,
                                message_json['actor'], nickname, domain, debug)
     if debug:
diff --git a/webapp_post.py b/webapp_post.py
index 6f332ca61..222f18b29 100644
--- a/webapp_post.py
+++ b/webapp_post.py
@@ -362,7 +362,7 @@ def _save_individual_post_as_html_to_cache(base_dir: str,
         with open(cached_post_filename, 'w+', encoding='utf-8') as fp_cache:
             fp_cache.write(post_html)
             return True
-    except Exception as ex:
+    except OSError as ex:
         print('ERROR: saving post to cache, ' + str(ex))
     return False
 
@@ -2133,9 +2133,13 @@ def individual_post_as_html(signing_priv_key_pem: str,
                                        translate, post_json_object['actor'],
                                        theme_name, system_language,
                                        box_name)
-                        with open(announce_filename + '.tts', 'w+',
-                                  encoding='utf-8') as ttsfile:
-                            ttsfile.write('\n')
+                        try:
+                            with open(announce_filename + '.tts', 'w+',
+                                      encoding='utf-8') as ttsfile:
+                                ttsfile.write('\n')
+                        except OSError:
+                            print('EX: unable to write tts ' +
+                                  announce_filename + '.tts')
 
         is_announced = True