Comparison

plugins/mod_mam/mod_mam.lua @ 7848:efe5232793aa

mod_mam: If archive:delete() gives a number, this should be the number of deleted items
author Kim Alvefur <zash@zash.se>
date Tue, 22 Nov 2016 18:19:55 +0100
parent 7846:22275bc5744a
child 7849:93a068ef4b2c
comparison
equal deleted inserted replaced
7847:c430932b8113 7848:efe5232793aa
324 if user then 324 if user then
325 module:log("debug", "Removing old messages for user %q", user); 325 module:log("debug", "Removing old messages for user %q", user);
326 local ok, err = archive:delete(user, { ["end"] = os.time() - cleanup_after; }) 326 local ok, err = archive:delete(user, { ["end"] = os.time() - cleanup_after; })
327 if not ok then 327 if not ok then
328 module:log("warn", "Could not expire archives for user %s: %s", user, err); 328 module:log("warn", "Could not expire archives for user %s: %s", user, err);
329 else 329 elseif type(ok) == "number" then
330 -- :affected() is a recent addition for eg SQLite3 in LuaDBI 330 module:log("debug", "Removed %d messages", ok);
331 pcall(function(stmt)
332 module:log("debug", "Removed %d messages", stmt:affected());
333 end, err);
334 end 331 end
335 cleanup[user] = nil; 332 cleanup[user] = nil;
336 end 333 end
337 return math.random(cleanup_interval, cleanup_interval * 2); 334 return math.random(cleanup_interval, cleanup_interval * 2);
338 end); 335 end);