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 2020/09/10 12:41:52 UTC

[incubator-ponymail-foal] 02/02: Add some notes to email docs when migrating

This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git

commit 19cf33d0773eeb163bbd9d2e278a4f997e4fda83
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Thu Sep 10 14:41:21 2020 +0200

    Add some notes to email docs when migrating
---
 tools/migrate.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/tools/migrate.py b/tools/migrate.py
index a1d14b8..a6620ee 100644
--- a/tools/migrate.py
+++ b/tools/migrate.py
@@ -57,6 +57,7 @@ async def main():
 
     # Let's get started..!
     start_time = time.time()
+    now = start_time
     processed = 0
     count = await es.count(index=old_dbname, doc_type="mbox")
     no_emails = count['count']
@@ -104,6 +105,18 @@ async def main():
         source['_source']['permalinks'] = doc['_source']['permalinks']
         doc['_source']['dbid'] = hashlib.sha3_256(source_text).hexdigest()
 
+        # Append migration details to notes field in doc
+        doc['_source']['notes'] = doc['_source'].get('notes', [])
+        # We want a list, not a single string
+        if isinstance(doc['_source']['notes'], str):
+            doc['_source']['notes'] = [doc['_source']['notes']]
+        doc['_source']['notes'].append("MIGRATE: Document migrated from Pony Mail to Pony Mail Foal at %u, "
+                                       "using foal migrator v/%s" % (now, MIGRATION_MAGIC_NUMBER))
+        # If we re-indexed the document, make a note of that as well.
+        if do_dkim:
+            doc['_source']['notes'].append("REINDEX: Document re-indexed with DKIM_ID at %u, "
+                                           "from %s to %s" % (now, dkim_id, old_id))
+
         # Copy to new DB
         bulk_array.append({
             'index': dbname_mbox,