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/09 16:16:43 UTC

[incubator-ponymail-foal] 02/02: If we hit a 404 on a source, fake the document, but don't assign a source

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 6630c727620c514c6d4ca1840040c056d457e96a
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Wed Sep 9 18:16:29 2020 +0200

    If we hit a 404 on a source, fake the document, but don't assign a source
---
 tools/migrate.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/tools/migrate.py b/tools/migrate.py
index 5d5e689..a1d14b8 100644
--- a/tools/migrate.py
+++ b/tools/migrate.py
@@ -50,7 +50,6 @@ async def main():
     if dkim_txt.lower() == 'n':
         do_dkim = False
 
-
     # Define index names for new ES
     dbname_mbox = new_dbprefix + "-mbox"
     dbname_source = new_dbprefix + "-source"
@@ -74,7 +73,16 @@ async def main():
         index=old_dbname,
     ):
         list_id = doc['_source']['list_raw'].strip("<>")
-        source = await es.get(index=old_dbname, doc_type="mbox_source", id=doc['_id'])
+        try:
+            source = await es.get(index=old_dbname, doc_type="mbox_source", id=doc['_id'])
+        # If we hit a 404 on a source, we have to fake an empty document, as we don't know the source.
+        except:
+            print("Source for %s was not found, faking it..." % doc['_id'])
+            source = {
+                '_source': {
+                    'source': ""
+                }
+            }
         source_text: str = source['_source']['source']
         if ':' not in source_text:  # Base64
             source_text = base64.b64decode(source_text)