From 0c6c1e5b1933d374c3a92949de169d72ed0e8e92 Mon Sep 17 00:00:00 2001 From: Jordan Bancino Date: Mon, 21 Nov 2022 16:22:50 +0000 Subject: [PATCH] Notify the user about the minimum max-cache instead of silently setting it. --- src/Db.c | 2 +- src/Telodendria.c | 15 ++++++++++++++- src/include/Db.h | 4 ++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Db.c b/src/Db.c index ab3c8cd..3e80ea7 100644 --- a/src/Db.c +++ b/src/Db.c @@ -236,7 +236,7 @@ DbOpen(char *dir, size_t cache) { Db *db; - if (!dir || cache < 1024) + if (!dir || cache < DB_MIN_CACHE) { return NULL; } diff --git a/src/Telodendria.c b/src/Telodendria.c index f863836..18b08b9 100644 --- a/src/Telodendria.c +++ b/src/Telodendria.c @@ -449,7 +449,20 @@ main(int argc, char **argv) if (!tConfig->maxCache) { - Log(lc, LOG_WARNING, "Max-cache is set to zero; caching is disabled."); + Log(lc, LOG_WARNING, "Max-cache is set to zero."); + Log(lc, LOG_WARNING, + "If this is not what you intended, check the config file"); + Log(lc, LOG_WARNING, + "and ensure that max-cache is a valid number of bytes."); + } + + if (tConfig->maxCache < DB_MIN_CACHE) + { + Log(lc, LOG_WARNING, + "Specified max cache size is less than the minimum of %d bytes.", + DB_MIN_CACHE); + Log(lc, LOG_WARNING, "Using a max-cache of %d bytes.", DB_MIN_CACHE); + tConfig->maxCache = DB_MIN_CACHE; } if (!matrixArgs.db) diff --git a/src/include/Db.h b/src/include/Db.h index 9d43813..97a928c 100644 --- a/src/include/Db.h +++ b/src/include/Db.h @@ -24,6 +24,10 @@ #ifndef TELODENDRIA_DB_H #define TELODENDRIA_DB_H +#ifndef DB_MIN_CACHE +#define DB_MIN_CACHE 1024 +#endif + #include #include