diff --git a/iarchiver/database.py b/iarchiver/database.py index f33f0df..8b74f3c 100644 --- a/iarchiver/database.py +++ b/iarchiver/database.py @@ -5,7 +5,7 @@ import time from pathlib import Path from typing import List -from iarchiver.mail import FileAttachment, FileAttachmentEncoder +from iarchiver.mail_conn import FileAttachment, FileAttachmentEncoder def is_valid_table_name(table_name): diff --git a/iarchiver/mail_conn.py b/iarchiver/mail_conn.py index 37a2965..8bd4e1f 100644 --- a/iarchiver/mail_conn.py +++ b/iarchiver/mail_conn.py @@ -111,7 +111,7 @@ class MailConnection: attachments = [] if email_message.is_multipart(): for part in email_message.walk(): - content_type = part.get_content_type() + # content_type = part.get_content_type() content_disposition = str(part.get("Content-Disposition")) if "attachment" in content_disposition: filename = part.get_filename() @@ -119,7 +119,7 @@ class MailConnection: # The filename of the file is the hash of its content, which should de-duplicate files. filecontents = part.get_payload(decode=True) filehash = md5_chunked(filecontents) - part.set_payload(filehash) # replace the attachment with its hash + part.set_payload(f'MD5:{filehash}') # replace the attachment with its hash filepath = self.attachments_dir / filehash file_obj = FileAttachment(filename, filehash) if not filepath.is_file(): diff --git a/run.py b/run.py index fd305c4..682c93d 100755 --- a/run.py +++ b/run.py @@ -10,7 +10,7 @@ import yaml from iarchiver.database import EmailDatabase from iarchiver.email import unix_timestamp_since_to_imap_timestamp -from iarchiver.mail import MailConnection +from iarchiver.mail_conn import MailConnection def main(args):