You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by se...@apache.org on 2016/11/13 02:44:15 UTC

incubator-ponymail git commit: Ensure doc check works properly even if the finds fail

Repository: incubator-ponymail
Updated Branches:
  refs/heads/master d04d4159c -> 19886b81b


Ensure doc check works properly even if the finds fail

If get by id fails, and the finds also fail, then code fails with:
site/api/email.lua:91: attempt to index local 'doc' (a string value)

This is because doc still contains the error message i.e. is true

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

Branch: refs/heads/master
Commit: 19886b81b05132a6d21482e4055ee183b6ec1093
Parents: d04d415
Author: Sebb <se...@apache.org>
Authored: Sun Nov 13 02:43:46 2016 +0000
Committer: Sebb <se...@apache.org>
Committed: Sun Nov 13 02:43:46 2016 +0000

----------------------------------------------------------------------
 site/api/email.lua | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/19886b81/site/api/email.lua
----------------------------------------------------------------------
diff --git a/site/api/email.lua b/site/api/email.lua
index 43f980c..a3c4705 100644
--- a/site/api/email.lua
+++ b/site/api/email.lua
@@ -45,7 +45,8 @@ function handle(r)
     local _, doc = pcall(function() return elastic.get("mbox", eid or "hmm") end)
     
     -- Try searching by original source mid if not found, for backward compat
-    if not doc or not doc.subject then
+    if not doc or not doc.mid then
+        doc = nil -- ensure subsequent check works if we don't find the email here either
         local docs = elastic.find("message-id:\"" .. r:escape(eid) .. "\"", 1, "mbox")
         if #docs == 1 then
             doc = docs[1]