]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fixed warning reported by luackeck 2376/head
authorMikhail Galanin <mgalanin@mimecast.com>
Thu, 26 Jul 2018 15:48:14 +0000 (16:48 +0100)
committerMikhail Galanin <mgalanin@mimecast.com>
Thu, 26 Jul 2018 15:48:14 +0000 (16:48 +0100)
src/plugins/lua/clickhouse.lua

index f93d96c59bdf1bf4075e7169b66b79020a84ee6a..7b7312136df78476d1932aa901468ecdea553967 100644 (file)
@@ -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