Handling removal of hashtags

main
Bob Mottram 2019-12-12 12:54:39 +00:00
parent a14bc1fd9c
commit 1a94e9b239
1 changed files with 9 additions and 5 deletions

View File

@ -360,11 +360,15 @@ def deletePost(baseDir: str,httpPrefix: str,nickname: str,domain: str,postFilena
continue continue
# remove postId from the tag index file # remove postId from the tag index file
with open(tagIndexFilename, "r") as f: with open(tagIndexFilename, "r") as f:
lines = f.readlines() lines=f.readlines()
with open(tagIndexFilename, "w+") as f: newlines=lines.replace(postId+'\n','')
for line in lines: if newlines!=lines:
if line.strip("\n") != postId: if not newlines.strip():
f.write(line) # if there are no lines then remove the hashtag file
os.remove(tagIndexFilename)
else:
with open(tagIndexFilename, "w+") as f:
f.write(newlines)
# remove any replies # remove any replies
repliesFilename=postFilename.replace('.json','.replies') repliesFilename=postFilename.replace('.json','.replies')