You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by hu...@apache.org on 2016/06/01 12:41:13 UTC

[11/11] incubator-ponymail git commit: make new MID generation optional, enable by default

make new MID generation optional, enable by default


Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/43d70910
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/43d70910
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/43d70910

Branch: refs/heads/master
Commit: 43d70910c09bcfb0aca94bf0e71050e60d039bb9
Parents: f507423
Author: humbedooh <hu...@apache.org>
Authored: Wed Jun 1 14:39:38 2016 +0200
Committer: humbedooh <hu...@apache.org>
Committed: Wed Jun 1 14:39:38 2016 +0200

----------------------------------------------------------------------
 tools/archiver.py | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/43d70910/tools/archiver.py
----------------------------------------------------------------------
diff --git a/tools/archiver.py b/tools/archiver.py
index b49472e..010e88e 100644
--- a/tools/archiver.py
+++ b/tools/archiver.py
@@ -296,7 +296,12 @@ class Archiver(object):
         if body or attachments:
             pmid = mid
             try:
-                mid = "%s@%s" % (hashlib.sha224(msg.as_bytes()).hexdigest(), lid)
+                # Use full message as bytes for mid?
+                if config.has_section('archiver') and config.has_option("archiver", "generator") and config.get("archiver", "generator") == "full":
+                    mid = "%s@%s" % (hashlib.sha224(msg.as_bytes()).hexdigest(), lid)
+                else:
+                    # Or revert to the old way?
+                    mid = "%s@%s@%s" % (hashlib.sha224(body if type(body) is bytes else body.encode('ascii', 'ignore')).hexdigest(), uid_mdate, lid)
             except Exception as err:
                 if logger:
                     logger.warn("Could not generate MID: %s" % err)
@@ -475,7 +480,7 @@ class Archiver(object):
                         )
                         if logger:
                             logger.info("Notification sent to %s for %s" % (cid, mid))
-        return lid
+        return lid, ojson['mid']
             
     def list_url(self, mlist):
         """ Gots
@@ -598,8 +603,8 @@ if __name__ == '__main__':
             msg_metadata = namedtuple('importmsg', ['list_id', 'archive_public'])(list_id = msg.get('list-id'), archive_public=ispublic)
             
             try:
-                lid = foo.archive_message(msg_metadata, msg)
-                print("%s: Done archiving to %s!" % (email.utils.formatdate(), lid))
+                lid, mid = foo.archive_message(msg_metadata, msg)
+                print("%s: Done archiving to %s as %s!" % (email.utils.formatdate(), lid, mid))
             except Exception as err:
                 if args.verbose:
                     import traceback