From: Vsevolod Stakhov Date: Mon, 25 Apr 2016 11:25:44 +0000 (+0100) Subject: [Fix] Remove bad FANN file to save computational resources X-Git-Tag: 1.3.0~634 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=4f4bad10a673961c4f613d4e536481574181a66a;p=rspamd.git [Fix] Remove bad FANN file to save computational resources --- 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