Ensure that line endings are removed

main
Bob Mottram 2020-05-21 23:23:15 +01:00
parent 949f52ae9b
commit 48f6bbf482
1 changed files with 1 additions and 3 deletions

View File

@ -51,14 +51,12 @@ def undoBookmarksCollectionEntry(recentPostsCache: {},
bookmarkIndex = postFilename.split('/')[-1].strip() bookmarkIndex = postFilename.split('/')[-1].strip()
else: else:
bookmarkIndex = postFilename.strip() bookmarkIndex = postFilename.strip()
bookmarkIndex = bookmarkIndex.replace('\n', '')
if bookmarkIndex not in open(bookmarksIndexFilename).read(): if bookmarkIndex not in open(bookmarksIndexFilename).read():
return return
indexStr = '' indexStr = ''
indexStrChanged = False
with open(bookmarksIndexFilename, 'r') as indexFile: with open(bookmarksIndexFilename, 'r') as indexFile:
indexStr = indexFile.read().replace(bookmarkIndex + '\n', '') indexStr = indexFile.read().replace(bookmarkIndex + '\n', '')
indexStrChanged = True
if indexStrChanged:
bookmarksIndexFile = open(bookmarksIndexFilename, 'w') bookmarksIndexFile = open(bookmarksIndexFilename, 'w')
if bookmarksIndexFile: if bookmarksIndexFile:
bookmarksIndexFile.write(indexStr) bookmarksIndexFile.write(indexStr)