forked from indymedia/epicyon
Check before adding new entries to indexes
parent
cce7941b39
commit
adbddb95c3
|
@ -204,6 +204,7 @@ def updateBookmarksCollection(recentPostsCache: {},
|
|||
try:
|
||||
with open(bookmarksIndexFilename, 'r+') as bmIndexFile:
|
||||
content = bmIndexFile.read()
|
||||
if bookmarkIndex + '\n' not in content:
|
||||
bmIndexFile.seek(0, 0)
|
||||
bmIndexFile.write(bookmarkIndex + '\n' + content)
|
||||
if debug:
|
||||
|
|
|
@ -725,8 +725,10 @@ def receiveFollowRequest(session, baseDir: str, httpPrefix: str,
|
|||
try:
|
||||
with open(followersFilename, 'r+') as followersFile:
|
||||
content = followersFile.read()
|
||||
if approveHandle + '\n' not in content:
|
||||
followersFile.seek(0, 0)
|
||||
followersFile.write(approveHandle + '\n' + content)
|
||||
followersFile.write(approveHandle + '\n' +
|
||||
content)
|
||||
except Exception as e:
|
||||
print('WARN: ' +
|
||||
'Failed to write entry to followers file ' +
|
||||
|
|
|
@ -96,6 +96,7 @@ def saveEventPost(baseDir: str, handle: str, postId: str,
|
|||
try:
|
||||
with open(tlEventsFilename, 'r+') as tlEventsFile:
|
||||
content = tlEventsFile.read()
|
||||
if eventId + '\n' not in content:
|
||||
tlEventsFile.seek(0, 0)
|
||||
tlEventsFile.write(eventId + '\n' + content)
|
||||
except Exception as e:
|
||||
|
|
1
inbox.py
1
inbox.py
|
@ -123,6 +123,7 @@ def storeHashTags(baseDir: str, nickname: str, postJsonObject: {}) -> None:
|
|||
try:
|
||||
with open(tagsFilename, 'r+') as tagsFile:
|
||||
content = tagsFile.read()
|
||||
if tagline not in content:
|
||||
tagsFile.seek(0, 0)
|
||||
tagsFile.write(tagline + content)
|
||||
except Exception as e:
|
||||
|
|
|
@ -184,8 +184,10 @@ def manualApproveFollowRequest(session, baseDir: str,
|
|||
try:
|
||||
with open(followersFilename, 'r+') as followersFile:
|
||||
content = followersFile.read()
|
||||
if approveHandleFull + '\n' not in content:
|
||||
followersFile.seek(0, 0)
|
||||
followersFile.write(approveHandleFull + '\n' + content)
|
||||
followersFile.write(approveHandleFull + '\n' +
|
||||
content)
|
||||
except Exception as e:
|
||||
print('WARN: Manual follow accept. ' +
|
||||
'Failed to write entry to followers file ' + str(e))
|
||||
|
|
|
@ -46,6 +46,7 @@ def _updateFeedsOutboxIndex(baseDir: str, domain: str, postId: str) -> None:
|
|||
try:
|
||||
with open(indexFilename, 'r+') as feedsFile:
|
||||
content = feedsFile.read()
|
||||
if postId + '\n' not in content:
|
||||
feedsFile.seek(0, 0)
|
||||
feedsFile.write(postId + '\n' + content)
|
||||
print('DEBUG: feeds post added to index')
|
||||
|
|
4
posts.py
4
posts.py
|
@ -668,8 +668,9 @@ def _updateHashtagsIndex(baseDir: str, tag: {}, newPostId: str) -> None:
|
|||
try:
|
||||
with open(tagsFilename, 'r+') as tagsFile:
|
||||
content = tagsFile.read()
|
||||
if tagline not in content:
|
||||
tagsFile.seek(0, 0)
|
||||
tagsFile.write(tagline+content)
|
||||
tagsFile.write(tagline + content)
|
||||
except Exception as e:
|
||||
print('WARN: Failed to write entry to tags file ' +
|
||||
tagsFilename + ' ' + str(e))
|
||||
|
@ -688,6 +689,7 @@ def _addSchedulePost(baseDir: str, nickname: str, domain: str,
|
|||
try:
|
||||
with open(scheduleIndexFilename, 'r+') as scheduleFile:
|
||||
content = scheduleFile.read()
|
||||
if indexStr + '\n' not in content:
|
||||
scheduleFile.seek(0, 0)
|
||||
scheduleFile.write(indexStr + '\n' + content)
|
||||
print('DEBUG: scheduled post added to index')
|
||||
|
|
Loading…
Reference in New Issue