On 19 September 2016 at 10:46, <humbed...@apache.org> wrote: > Repository: incubator-ponymail > Updated Branches: > refs/heads/null-bodies [created] 81bd75a42 > > > Ensure that we have a body, even if it's empty/nonexistent in reality > > > Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo > Commit: > http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/81bd75a4 > Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/81bd75a4 > Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/81bd75a4 > > Branch: refs/heads/null-bodies > Commit: 81bd75a42ce8fa3387c3bc371785de96f2ee047b > Parents: 07e8338 > Author: Daniel Gruno <humbed...@apache.org> > Authored: Mon Sep 19 11:44:54 2016 +0200 > Committer: Daniel Gruno <humbed...@apache.org> > Committed: Mon Sep 19 11:44:54 2016 +0200 > > ---------------------------------------------------------------------- > site/api/stats.lua | 2 ++ > tools/archiver.py | 3 +++ > 2 files changed, 5 insertions(+) > ---------------------------------------------------------------------- > > > http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/81bd75a4/site/api/stats.lua > ---------------------------------------------------------------------- > diff --git a/site/api/stats.lua b/site/api/stats.lua > index 078885c..3729c89 100644 > --- a/site/api/stats.lua > +++ b/site/api/stats.lua > @@ -693,6 +693,8 @@ function handle(r) > table.insert(threads, emails[mid]) > end > if not statsOnly then > + -- Make sure email.body is not NULL, as can happen with > the current archiver > + email.body = (email.body and email.body ~= JSON.null) > and email.body or ""
Why not code this as: if (email.body and email.body == JSON.null) then email.body = "" end It seems odd to use a conditional assignment when one of the assignments is effectively a no-op. IMO it's also harder to read the conditional assignment. One would not write: if (email.body and email.body == JSON.null) then email.body = "" else email.body = email.body end but that's what the conditional assigment is equivalent to. > threads[#threads].body = #email.body < 300 and > email.body or email.body:sub(1,300) .. "..." > end > end > > http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/81bd75a4/tools/archiver.py > ---------------------------------------------------------------------- > diff --git a/tools/archiver.py b/tools/archiver.py > index d8efc5f..1acf83a 100644 > --- a/tools/archiver.py > +++ b/tools/archiver.py > @@ -296,6 +296,9 @@ class Archiver(object): > attachments, contents = self.msgfiles(msg) > irt = "" > if body or attachments: > + ## If we only have attachments, set body as an empty string > + if not body: > + body = "" > pmid = mid > try: > # Use full message as bytes for mid? >