From 05ea2e289cc95177928665b5e96cdf575f70d54a Mon Sep 17 00:00:00 2001 From: Mikhail Galanin Date: Thu, 26 Jul 2018 16:48:14 +0100 Subject: [PATCH] [Minor] Fixed warning reported by luackeck --- src/plugins/lua/clickhouse.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/plugins/lua/clickhouse.lua b/src/plugins/lua/clickhouse.lua index f93d96c59..7b7312136 100644 --- a/src/plugins/lua/clickhouse.lua +++ b/src/plugins/lua/clickhouse.lua @@ -856,18 +856,18 @@ local function get_last_removal_ago() f:close() end - write_file, err = io.open(ts_file, 'w') - if err then - rspamd_logger.errx(rspamd_config, 'Failed to open %s, will not perform retention: %s', ts_file, err) - return nil - end - local current_ts = os.time() if last_ts == nil or (last_ts + settings.retention.period) <= current_ts then + write_file, err = io.open(ts_file, 'w') + if err then + rspamd_logger.errx(rspamd_config, 'Failed to open %s, will not perform retention: %s', ts_file, err) + return nil + end + local res res, err = write_file:write(tostring(current_ts)) - if err then + if err or res == nil then rspamd_logger.errx(rspamd_config, 'Failed to write %s, will not perform retention: %s', ts_file, err) return nil end -- 2.39.5