diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-01-26 21:12:30 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-01-26 21:12:30 +0000 |
commit | 859c38cf85626f771d437a8da1004fd66aec55d7 (patch) | |
tree | 90e68a2d90c668fe4c85b95ebff7e0afb936782d /src/libserver | |
parent | 213d099065c3daedfcc50e7d8ff2625081b92ba2 (diff) | |
download | rspamd-859c38cf85626f771d437a8da1004fd66aec55d7.tar.gz rspamd-859c38cf85626f771d437a8da1004fd66aec55d7.zip |
Create fuzzy db if it does not exist.
Diffstat (limited to 'src/libserver')
-rw-r--r-- | src/libserver/fuzzy_backend.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/libserver/fuzzy_backend.c b/src/libserver/fuzzy_backend.c index c513ad06f..df35e0ccf 100644 --- a/src/libserver/fuzzy_backend.c +++ b/src/libserver/fuzzy_backend.c @@ -498,25 +498,30 @@ rspamd_fuzzy_backend_open (const gchar *path, GError **err) } g_free (dir); + if ((fd = open (path, O_RDONLY)) == -1) { - g_set_error (err, rspamd_fuzzy_backend_quark (), - errno, "Cannot open file %s: %s", - path, strerror (errno)); + if (errno != ENOENT) { + g_set_error (err, rspamd_fuzzy_backend_quark (), + errno, "Cannot open file %s: %s", + path, strerror (errno)); - return NULL; + return NULL; + } } + else { - /* Check for legacy format */ - if ((r = read (fd, header, sizeof (header))) == sizeof (header)) { - if (memcmp (header, FUZZY_FILE_MAGIC, sizeof (header) - 1) == 0) { - msg_info ("Trying to convert old fuzzy database"); - if (!rspamd_fuzzy_backend_convert (path, fd, err)) { - close (fd); - return NULL; + /* Check for legacy format */ + if ((r = read (fd, header, sizeof (header))) == sizeof (header)) { + if (memcmp (header, FUZZY_FILE_MAGIC, sizeof (header) - 1) == 0) { + msg_info ("Trying to convert old fuzzy database"); + if (!rspamd_fuzzy_backend_convert (path, fd, err)) { + close (fd); + return NULL; + } + msg_info ("Old database converted"); } - msg_info ("Old database converted"); + close (fd); } - close (fd); } /* Open database */ |