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