From 4f4bad10a673961c4f613d4e536481574181a66a Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 25 Apr 2016 12:25:44 +0100 Subject: [PATCH] [Fix] Remove bad FANN file to save computational resources --- src/plugins/lua/fann_scores.lua | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/plugins/lua/fann_scores.lua b/src/plugins/lua/fann_scores.lua index 5085c90a6..b20338fb8 100644 --- a/src/plugins/lua/fann_scores.lua +++ b/src/plugins/lua/fann_scores.lua @@ -69,12 +69,25 @@ local function load_fann() if n ~= fann:get_inputs() then rspamd_logger.infox(rspamd_config, 'fann has incorrect number of inputs: %s, %s symbols' .. - ' is found in the cache', fann:get_inputs(), n) + ' is found in the cache; removing', fann:get_inputs(), n) fann = nil + + local ret,err = rspamd_util.unlink(fann_file) + if not ret then + rspamd_logger.errx(rspamd_config, 'cannot remove invalid fann from %s: %s', + fann_file, err) + end else rspamd_logger.infox(rspamd_config, 'loaded fann from %s', fann_file) return true end + else + rspamd_logger.infox(rspamd_config, 'fann is invalid: "%s"; removing', fann_file) + local ret,err = rspamd_util.unlink(fann_file) + if not ret then + rspamd_logger.errx(rspamd_config, 'cannot remove invalid fann from %s: %s', + fann_file, err) + end end return false -- 2.39.5