forked from indymedia/epicyon
Clear inbox queue when full
parent
b749b37187
commit
83345a6d84
|
@ -64,6 +64,7 @@ from posts import createDirectMessagePost
|
||||||
from posts import populateRepliesJson
|
from posts import populateRepliesJson
|
||||||
from posts import addToField
|
from posts import addToField
|
||||||
from posts import expireCache
|
from posts import expireCache
|
||||||
|
from inbox import clearQueueItems
|
||||||
from inbox import inboxPermittedMessage
|
from inbox import inboxPermittedMessage
|
||||||
from inbox import inboxMessageHasParams
|
from inbox import inboxMessageHasParams
|
||||||
from inbox import runInboxQueue
|
from inbox import runInboxQueue
|
||||||
|
@ -820,9 +821,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
else:
|
else:
|
||||||
print('Queue: Inbox queue is full')
|
print('Queue: Inbox queue is full')
|
||||||
self._503()
|
self._503()
|
||||||
self.server.POSTbusy = False
|
clearQueueItems(self.server.baseDir, self.server.inboxQueue)
|
||||||
if not self.server.restartInboxQueueInProgress:
|
if not self.server.restartInboxQueueInProgress:
|
||||||
self.server.restartInboxQueue = True
|
self.server.restartInboxQueue = True
|
||||||
|
self.server.POSTbusy = False
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
# Convert the headers needed for signature verification to dict
|
# Convert the headers needed for signature verification to dict
|
||||||
|
|
23
inbox.py
23
inbox.py
|
@ -2212,6 +2212,26 @@ def inboxAfterCapabilities(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def clearQueueItems(baseDir: str, queue: []) -> None:
|
||||||
|
"""Clears the queue for each account and appends filenames
|
||||||
|
"""
|
||||||
|
ctr = 0
|
||||||
|
queue.clear()
|
||||||
|
for subdir, dirs, files in os.walk(baseDir + '/accounts'):
|
||||||
|
for account in dirs:
|
||||||
|
queueDir = baseDir + '/accounts/' + account + '/queue'
|
||||||
|
if os.path.isdir(queueDir):
|
||||||
|
for queuesubdir, queuedirs, queuefiles in os.walk(queueDir):
|
||||||
|
for qfile in queuefiles:
|
||||||
|
try:
|
||||||
|
os.remove(os.path.join(queueDir, qfile))
|
||||||
|
ctr += 1
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
if ctr > 0:
|
||||||
|
print('Removed ' + str(ctr) + ' inbox queue items')
|
||||||
|
|
||||||
|
|
||||||
def restoreQueueItems(baseDir: str, queue: []) -> None:
|
def restoreQueueItems(baseDir: str, queue: []) -> None:
|
||||||
"""Checks the queue for each account and appends filenames
|
"""Checks the queue for each account and appends filenames
|
||||||
"""
|
"""
|
||||||
|
@ -2220,11 +2240,8 @@ def restoreQueueItems(baseDir: str, queue: []) -> None:
|
||||||
for account in dirs:
|
for account in dirs:
|
||||||
queueDir = baseDir + '/accounts/' + account + '/queue'
|
queueDir = baseDir + '/accounts/' + account + '/queue'
|
||||||
if os.path.isdir(queueDir):
|
if os.path.isdir(queueDir):
|
||||||
print('Searching inbox queue ' + queueDir)
|
|
||||||
for queuesubdir, queuedirs, queuefiles in os.walk(queueDir):
|
for queuesubdir, queuedirs, queuefiles in os.walk(queueDir):
|
||||||
for qfile in queuefiles:
|
for qfile in queuefiles:
|
||||||
print('Adding inbox queue file ' +
|
|
||||||
os.path.join(queueDir, qfile))
|
|
||||||
queue.append(os.path.join(queueDir, qfile))
|
queue.append(os.path.join(queueDir, qfile))
|
||||||
if len(queue) > 0:
|
if len(queue) > 0:
|
||||||
print('Restored ' + str(len(queue)) + ' inbox queue items')
|
print('Restored ' + str(len(queue)) + ' inbox queue items')
|
||||||
|
|
Loading…
Reference in New Issue