mirror of https://gitlab.com/bashrc2/epicyon
Recalculate the newswire if a new blog post is created
parent
0a110e2aaa
commit
57fcdcca38
|
@ -255,6 +255,7 @@ from newswire import rss2Footer
|
|||
from newswire import loadHashtagCategories
|
||||
from newsdaemon import runNewswireWatchdog
|
||||
from newsdaemon import runNewswireDaemon
|
||||
from newsdaemon import refreshNewswire
|
||||
from filters import isFiltered
|
||||
from filters import addGlobalFilter
|
||||
from filters import removeGlobalFilter
|
||||
|
@ -12444,6 +12445,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if fields['schedulePost']:
|
||||
return 1
|
||||
if self._postToOutbox(messageJson, __version__, nickname):
|
||||
refreshNewswire(self.server.baseDir)
|
||||
populateReplies(self.server.baseDir,
|
||||
self.server.httpPrefix,
|
||||
self.server.domainFull,
|
||||
|
|
|
@ -660,6 +660,7 @@ def runNewswireDaemon(baseDir: str, httpd,
|
|||
"""Periodically updates RSS feeds
|
||||
"""
|
||||
newswireStateFilename = baseDir + '/accounts/.newswirestate.json'
|
||||
refreshFilename = baseDir + '/accounts/.refresh_newswire'
|
||||
|
||||
# initial sleep to allow the system to start up
|
||||
time.sleep(50)
|
||||
|
@ -722,7 +723,16 @@ def runNewswireDaemon(baseDir: str, httpd,
|
|||
httpd.maxNewsPosts)
|
||||
|
||||
# wait a while before the next feeds update
|
||||
time.sleep(1200)
|
||||
for tick in range(120):
|
||||
time.sleep(10)
|
||||
# if a new blog post has been created then stop
|
||||
# waiting and recalculate the newswire
|
||||
if os.path.isfile(refreshFilename):
|
||||
try:
|
||||
os.remove(refreshFilename)
|
||||
except BaseException:
|
||||
pass
|
||||
break
|
||||
|
||||
|
||||
def runNewswireWatchdog(projectVersion: str, httpd) -> None:
|
||||
|
@ -740,3 +750,15 @@ def runNewswireWatchdog(projectVersion: str, httpd) -> None:
|
|||
newswireOriginal.clone(runNewswireDaemon)
|
||||
httpd.thrNewswireDaemon.start()
|
||||
print('Restarting newswire daemon...')
|
||||
|
||||
|
||||
def refreshNewswire(baseDir: str) -> None:
|
||||
"""Causes the newswire to be updated.
|
||||
This creates a file which is then detected by the daemon
|
||||
"""
|
||||
refreshFilename = baseDir + '/accounts/.refresh_newswire'
|
||||
if os.path.isfile(refreshFilename):
|
||||
return
|
||||
refreshFile = open(refreshFilename, 'w+')
|
||||
refreshFile.write('\n')
|
||||
refreshFile.close()
|
||||
|
|
Loading…
Reference in New Issue