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/12/19 00:41:02 UTC

incubator-ponymail git commit: get does not return if a document is 404 but some callers overlook this

Repository: incubator-ponymail
Updated Branches:
  refs/heads/master 4de111760 -> b8ed9186e


get does not return if a document is 404 but some callers overlook this 

This fixes #137
It looks as though the only such caller is source.lua

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

Branch: refs/heads/master
Commit: b8ed9186efccc1e2e879e9723519b0d0d78dbcf9
Parents: 4de1117
Author: Sebb <se...@apache.org>
Authored: Mon Dec 19 00:40:43 2016 +0000
Committer: Sebb <se...@apache.org>
Committed: Mon Dec 19 00:40:43 2016 +0000

----------------------------------------------------------------------
 CHANGELOG.md        | 1 +
 site/api/source.lua | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/b8ed9186/CHANGELOG.md
----------------------------------------------------------------------
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b8bc46b..2891379 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -88,6 +88,7 @@
 - Move extractCanonEmail to utils
 - preferences does not properly remove nulls from account.credentials.altemail (#309)
 - manage e-mails can create multiple identical alternate addresses (#307)
+- elastic.get does not return if a document is not found but some callers overlook this (#137)
 
 ## CHANGES in 0.9b:
 

http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/b8ed9186/site/api/source.lua
----------------------------------------------------------------------
diff --git a/site/api/source.lua b/site/api/source.lua
index f0e8710..afcee70 100644
--- a/site/api/source.lua
+++ b/site/api/source.lua
@@ -27,7 +27,7 @@ function handle(r)
     cross.contentType(r, "text/plain")
     local get = r:parseargs()
     local eid = (get.id or r.path_info):gsub("\"", ""):gsub("/", "")
-    local doc = elastic.get("mbox", eid or "hmm")
+    local _, doc = pcall(function() return elastic.get("mbox", eid or "hmm") end)
     
     -- Try searching by mid if not found, for backward compat
     if not doc or not doc.mid then
@@ -36,7 +36,7 @@ function handle(r)
             doc = docs[1]
         end
     end
-    if doc then
+    if doc and doc.mid then
         local account = user.get(r)
         if aaa.canAccessDoc(r, doc, account) then
             doc.tid = doc.request_id