From 7eca0b33bec329af21b8a5bfb3f1f08a7a850f21 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 12 Dec 2019 17:47:16 +0000 Subject: [PATCH] Prepend to tags file --- inbox.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/inbox.py b/inbox.py index da34f3bf9..965234c76 100644 --- a/inbox.py +++ b/inbox.py @@ -94,10 +94,13 @@ def storeHashTags(baseDir: str,postJsonObject: {}) -> None: tagsFile.close() else: if postUrl not in open(tagsFilename).read(): - tagsFile=open(tagsFilename, "a+") - if tagsFile: - tagsFile.write(postUrl+'\n') - tagsFile.close() + try: + with open(tagsFilename, 'r+') as tagsFile: + content = tagsFile.read() + tagsFile.seek(0, 0) + tagsFile.write(postUrl+'\n'+content) + except: + pass def inboxStorePostToHtmlCache(recentPostsCache: {},maxRecentPosts: int, \ translate: {}, \