diff options
author | Adrian C. (anrxc) <anrxc@sysphere.org> | 2009-10-04 00:31:12 +0200 |
---|---|---|
committer | Adrian C. (anrxc) <anrxc@sysphere.org> | 2009-10-04 16:06:33 +0200 |
commit | 49bddbf558ebbf638275819587477eb0b95d135f (patch) | |
tree | 93cd7febb52e8136eceea197dae62ab438e55bea /mboxc.lua | |
parent | c55614d449217c9478f37de91c64148c6d56dc35 (diff) | |
download | vicious-legacy-49bddbf558ebbf638275819587477eb0b95d135f.tar.xz |
Reworked counters in mboxc, mdir, org
Diffstat (limited to 'mboxc.lua')
-rw-r--r-- | mboxc.lua | 40 |
1 files changed, 18 insertions, 22 deletions
@@ -17,34 +17,30 @@ module("vicious.mboxc") -- {{{ Mbox count widget type local function worker(format, mbox) -- Initialise counters - local count = { - old = 0, - total = 0, - new = 0 - } + local count = { old = 0, total = 0, new = 0 } -- Get data from mbox files for i=1, #mbox do local f = io.open(mbox[i]) while true do - -- Read the mbox line by line, if we are going to read some - -- *HUGE* folders then switch to reading chunks - local lines = f:read("*line") - if not lines then break end - - -- Find all messages - -- * http://www.jwz.org/doc/content-length.html - local _, from = string.find(lines, "^From[%s]") - if from ~= nil then count.total = count.total + 1 end - - -- Read messages have the Status header - local _, status = string.find(lines, "^Status:[%s]RO$") - if status ~= nil then count.old = count.old + 1 end - - -- Skip the folder internal data - local _, intdata = string.find(lines, "^Subject:[%s].*FOLDER[%s]INTERNAL[%s]DATA") - if intdata ~= nil then count.total = count.total - 1 end + -- Read the mbox line by line, if we are going to read some + -- *HUGE* folders then switch to reading chunks + local lines = f:read("*line") + if not lines then break end + + -- Find all messages + -- * http://www.jwz.org/doc/content-length.html + local _, from = string.find(lines, "^From[%s]") + if from ~= nil then count.total = count.total + 1 end + + -- Read messages have the Status header + local _, status = string.find(lines, "^Status:[%s]RO$") + if status ~= nil then count.old = count.old + 1 end + + -- Skip the folder internal data + local _, int = string.find(lines, "^Subject:[%s].*FOLDER[%s]INTERNAL[%s]DATA") + if int ~= nil then count.total = count.total - 1 end end f:close() end |