* some of these attachments are already in the database...
- so we need to update the DB..
- probably worth putting the code in a stored procedure..
+
+ -- key scenarios
+ * first scan (and extract)
+ * rescan (as I messed up the first time - fix the DB...)
+ * email scan - attachments might not have related messages.
+
+
- {id} attachment_init(
{exim_msg_id}
{chksum}
{filename),
)
+ // creates or returns id (can look for existing messages?
+ // can do a merge?? - copy 'old' record data into 'new'.... "prefer checksummed"
+
attachment_update(
{id}
{exim_msg_id}
return;
}
this.query("""
- UPDATE
- Attachment
- SET
- queue_id = COALESCE((SELECT id from MailQueue where msgid = '%s' AND message_sig = '%s' AND msgid != '' AND message_sig != '' LIMIT 1),0),
- mime_cdisp = 'attachment',
- mime_size = filesize,
-
- mime_is_cover = 0,
- mime_is_multi = 0,
- mime_is_mail = 0,
-
- msgid = '%s',
- maillog_id = COALESCE((SELECT id from email_log where msgid = '%s' AND message_sig = '%s' AND msgid != '' AND message_sig != '' LIMIT 1),0),
- delivered = created
- WHERE
- id = %d
- AND
- id != 0
- AND
- (queue_id IS NULL OR queue_id = 0)
- AND
- delivered is NULL
- LIMIT 1
+ SELECT attachment_update(
+ %d, -- in_id INT(11),
+ '%s', -- in_mime_type varchar(255),
+ %d, -- in_mime_size int(11),
+ '%s', -- in_created DATETIME,
+ '%s' -- in_mailfort_sig varchar(64)
+
+ )""
+
""".printf(
- this.mysql_escape(this.active_message_exim_id), this.mysql_escape(this.active_message_x_mailfort_sig),
-
- this.mysql_escape(this.active_message_exim_id),
- this.mysql_escape(this.active_message_exim_id), this.mysql_escape(this.active_message_x_mailfort_sig),
- int.parse(sid)
+ int.parse(sid),
+ "", // this will be ignored..
+ 0, // this will be ingored..
+ this.created_date,
+ this.mysql_escape(this.active_message_x_mailfort_sig)
)
);