mirror of https://gitlab.com/bashrc2/epicyon
Removing bookmarks from index
parent
3b83a30e41
commit
79789014d4
22
bookmarks.py
22
bookmarks.py
|
@ -29,7 +29,9 @@ def undoBookmarksCollectionEntry(baseDir: str,postFilename: str,objectUrl: str,
|
|||
"""Undoes a bookmark for a particular actor
|
||||
"""
|
||||
postJsonObject=loadJson(postFilename)
|
||||
if postJsonObject:
|
||||
if not postJsonObject:
|
||||
return
|
||||
|
||||
# remove any cached version of this post so that the bookmark icon is changed
|
||||
nickname=getNicknameFromActor(actor)
|
||||
cachedPostFilename= \
|
||||
|
@ -66,7 +68,10 @@ def undoBookmarksCollectionEntry(baseDir: str,postFilename: str,objectUrl: str,
|
|||
postJsonObject['object']['bookmarks']['items'].remove(bookmarkItem)
|
||||
itemFound=True
|
||||
break
|
||||
if itemFound:
|
||||
|
||||
if not itemFound:
|
||||
return
|
||||
|
||||
if totalItems==1:
|
||||
if debug:
|
||||
print('DEBUG: bookmarks was removed from post')
|
||||
|
@ -78,13 +83,18 @@ def undoBookmarksCollectionEntry(baseDir: str,postFilename: str,objectUrl: str,
|
|||
|
||||
# remove from the index
|
||||
bookmarksIndexFilename=baseDir+'/accounts/'+nickname+'@'+domain+'/bookmarks.index'
|
||||
if os.path.isfile(bookmarksIndexFilename):
|
||||
bookmarkIndex=postFilename.split('/')[-1]+'\n'
|
||||
if bookmarkIndex in open(bookmarksIndexFilename).read():
|
||||
if not os.path.isfile(bookmarksIndexFilename):
|
||||
return
|
||||
if '/' in postFilename:
|
||||
bookmarkIndex=postFilename.split('/')[-1].strip()
|
||||
else:
|
||||
bookmarkIndex=postFilename.strip()
|
||||
if bookmarkIndex not in open(bookmarksIndexFilename).read():
|
||||
return
|
||||
indexStr=''
|
||||
indexStrChanged=False
|
||||
with open(bookmarksIndexFilename, 'r') as indexFile:
|
||||
indexStr=indexFile.read().replace(bookmarkIndex,'')
|
||||
indexStr=indexFile.read().replace(bookmarkIndex+'\n','')
|
||||
indexStrChanged=True
|
||||
if indexStrChanged:
|
||||
bookmarksIndexFile=open(bookmarksIndexFilename,'w')
|
||||
|
|
Loading…
Reference in New Issue