bug fix data may be referenced when not set

This commit is contained in:
alligatorbait 2020-10-14 16:58:37 -06:00
parent 628b734451
commit eca0f16806

View File

@ -154,8 +154,6 @@ def imap_sync(q, logger, server):
try: try:
status, data = server.search(None, 'NOT', 'DELETED') status, data = server.search(None, 'NOT', 'DELETED')
except imaplib.IMAP4.error:
logger.error("IMAP retrieve failed. Is the folder '%s' spelled correctly, and does it exist on the server?" % q.email_box_imap_folder)
if data: if data:
msgnums = data[0].split() msgnums = data[0].split()
logger.info("Received %d messages from IMAP server" % len(msgnums)) logger.info("Received %d messages from IMAP server" % len(msgnums))
@ -172,6 +170,8 @@ def imap_sync(q, logger, server):
logger.info("Successfully processed message %s, deleted from IMAP server" % num) logger.info("Successfully processed message %s, deleted from IMAP server" % num)
else: else:
logger.warn("Message %s was not successfully processed, and will be left on IMAP server" % num) logger.warn("Message %s was not successfully processed, and will be left on IMAP server" % num)
except imaplib.IMAP4.error:
logger.error("IMAP retrieve failed. Is the folder '%s' spelled correctly, and does it exist on the server?" % q.email_box_imap_folder)
server.expunge() server.expunge()
server.close() server.close()