forked from indymedia/epicyon
Save newswire state at time of vote changes
parent
344617f8c9
commit
f405dbead3
12
daemon.py
12
daemon.py
|
@ -4721,6 +4721,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if 'vote:' + nickname not in newswire[dateStr][2]:
|
||||
newswire[dateStr][2].append('vote:' + nickname)
|
||||
filename = newswire[dateStr][3]
|
||||
try:
|
||||
newswireStateFilename = \
|
||||
baseDir + '/accounts/.newswirestate.json'
|
||||
saveJson(newswire, newswireStateFilename)
|
||||
except Exception as e:
|
||||
print('ERROR saving newswire state, ' + str(e))
|
||||
if filename:
|
||||
saveJson(newswire[dateStr][2],
|
||||
filename + '.votes')
|
||||
|
@ -4762,6 +4768,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if 'vote:' + nickname in newswire[dateStr][2]:
|
||||
newswire[dateStr][2].remove('vote:' + nickname)
|
||||
filename = newswire[dateStr][3]
|
||||
try:
|
||||
newswireStateFilename = \
|
||||
baseDir + '/accounts/.newswirestate.json'
|
||||
saveJson(newswire, newswireStateFilename)
|
||||
except Exception as e:
|
||||
print('ERROR saving newswire state, ' + str(e))
|
||||
if filename:
|
||||
saveJson(newswire[dateStr][2],
|
||||
filename + '.votes')
|
||||
|
|
|
@ -146,7 +146,7 @@ def runNewswireDaemon(baseDir: str, httpd,
|
|||
translate: {}) -> None:
|
||||
"""Periodically updates RSS feeds
|
||||
"""
|
||||
newswireFilename = baseDir + '/accounts/.currentnewswire.json'
|
||||
newswireStateFilename = baseDir + '/accounts/.newswirestate.json'
|
||||
|
||||
# initial sleep to allow the system to start up
|
||||
time.sleep(50)
|
||||
|
@ -167,13 +167,13 @@ def runNewswireDaemon(baseDir: str, httpd,
|
|||
continue
|
||||
|
||||
if not httpd.newswire:
|
||||
if os.path.isfile(newswireFilename):
|
||||
httpd.newswire = loadJson(newswireFilename)
|
||||
if os.path.isfile(newswireStateFilename):
|
||||
httpd.newswire = loadJson(newswireStateFilename)
|
||||
|
||||
mergeWithPreviousNewswire(httpd.newswire, newNewswire)
|
||||
|
||||
httpd.newswire = newNewswire
|
||||
saveJson(httpd.newswire, newswireFilename)
|
||||
saveJson(httpd.newswire, newswireStateFilename)
|
||||
print('Newswire updated')
|
||||
|
||||
convertRSStoActivityPub(baseDir,
|
||||
|
|
Loading…
Reference in New Issue