forked from indymedia/epicyon
Handling removal of hashtags
parent
a14bc1fd9c
commit
1a94e9b239
14
utils.py
14
utils.py
|
@ -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')
|
||||||
|
|
Loading…
Reference in New Issue