From ce2d95f33854ffe8719eee25c64207e8d2d5d5f0 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 12 Jul 2019 22:09:23 +0100 Subject: [PATCH] Reload any outstanding queue items --- inbox.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/inbox.py b/inbox.py index 8b941deda..b7f1621c0 100644 --- a/inbox.py +++ b/inbox.py @@ -787,6 +787,18 @@ def inboxAfterCapabilities(session,keyId: str,handle: str,messageJson: {}, \ copyfile(queueFilename,destinationFilename) return True +def restoreQueueItems(baseDir: str,queue: []) -> None: + """Checks the queue for each account and appends filenames + """ + queue=[] + 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: + queue.append(os.path.join(queueDir, qfile)) + def runInboxQueue(baseDir: str,httpPrefix: str,sendThreads: [],postLog: [], \ cachedWebfingers: {},personCache: {},queue: [], \ domain: str,port: int,useTor: bool,federationList: [], \ @@ -802,6 +814,10 @@ def runInboxQueue(baseDir: str,httpPrefix: str,sendThreads: [],postLog: [], \ if debug: print('DEBUG: Inbox queue running') + # if queue processing was interrupted (eg server crash) + # then this loads any outstanding items back into the queue + restoreQueueItems(baseDir,queue) + while True: time.sleep(1) if len(queue)>0: