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 2021/03/31 16:54:10 UTC

[incubator-ponymail-foal] branch master updated: make audit logging conditional on audit log existing

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


The following commit(s) were added to refs/heads/master by this push:
     new 3be0b54  make audit logging conditional on audit log existing
3be0b54 is described below

commit 3be0b54f93a957c310a89d09eac7d45e82ba62e2
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Wed Mar 31 18:54:01 2021 +0200

    make audit logging conditional on audit log existing
---
 tools/archiver.py | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/tools/archiver.py b/tools/archiver.py
index a940d2f..b12a238 100755
--- a/tools/archiver.py
+++ b/tools/archiver.py
@@ -570,18 +570,19 @@ class Archiver(object):  # N.B. Also used by import-mbox.py
             )
 
             # Write to audit log
-            elastic.index(
-                index=elastic.db_auditlog,
-                body={
-                    "date": time.strftime("%Y/%m/%d %H:%M:%S", time.gmtime(time.time())),
-                    "action": "index",
-                    "remote": "internal",
-                    "author": "archiver.py",
-                    "target": ojson["mid"],
-                    "lid": lid,
-                    "log": f"Indexed email {ojson['message-id']} for {lid} as {ojson['mid']}",
-                }
-            )
+            if elastic.indices.exists(index=elastic.db_auditlog):
+                elastic.index(
+                    index=elastic.db_auditlog,
+                    body={
+                        "date": time.strftime("%Y/%m/%d %H:%M:%S", time.gmtime(time.time())),
+                        "action": "index",
+                        "remote": "internal",
+                        "author": "archiver.py",
+                        "target": ojson["mid"],
+                        "lid": lid,
+                        "log": f"Indexed email {ojson['message-id']} for {lid} as {ojson['mid']}",
+                    }
+                )
 
         # If we have a dump dir and ES failed, push to dump dir instead as a JSON object
         # We'll leave it to another process to pick up the slack.