def purge_thread(self, threadid):
self.purges.add(int(threadid))
- def store(self, conn, listid, overwrite=False):
+ def store(self, conn, listid, overwrite=False, overwrite_raw=False):
curs = conn.cursor()
# Potentially add the information that there exists a mail for
if overwrite:
pk = r[0][2]
self.purge_thread(r[0][0])
+ if overwrite_raw:
+ # For full overwrite, we also update the raw text of the message. This is an
+ # uncommon enough operation that we'll just do it as a separate command.
+ log.status("Full raw overwrite of %s" % self.msgid)
+ curs.execute("UPDATE messages SET rawtxt=%(raw)s WHERE id=%(id)s", {
+ 'raw': bytearray(self.rawtxt),
+ 'id': pk,
+ })
+
# Overwrite an existing message. We do not attempt to
# "re-thread" a message, we just update the contents. We
# do remove all attachments and rewrite them. Of course, we
optparser.add_option('-v', '--verbose', dest='verbose', action='store_true', help='Verbose output')
optparser.add_option('--force-date', dest='force_date', help='Override date (used for dates that can\'t be parsed)')
optparser.add_option('--filter-msgid', dest='filter_msgid', help='Only process message with given msgid')
+ optparser.add_option('--overwrite', dest='overwrite', action='store_true', help='Overwrite full contents of message')
(opt, args) = optparser.parse_args()
log_failed_message(listid, "directory", os.path.join(opt.directory, x), ap, e)
opstatus.failed += 1
continue
- ap.store(conn, listid)
+ ap.store(conn, listid, opt.overwrite, opt.overwrite)
purges.update(ap.purges)
if opt.interactive:
print("Interactive mode, committing transaction")
log_failed_message(listid, "mbox", opt.mbox, ap, e)
opstatus.failed += 1
continue
- ap.store(conn, listid)
+ ap.store(conn, listid, opt.overwrite, opt.overwrite)
purges.update(ap.purges)
if mboxparser.returncode():
log.error("Failed to parse mbox:")
log_failed_message(listid, "stdin", "", ap, e)
conn.close()
sys.exit(1)
- ap.store(conn, listid)
+ ap.store(conn, listid, opt.overwrite, opt.overwrite)
purges.update(ap.purges)
if opstatus.stored:
log.log("Stored message with message-id %s" % ap.msgid)