From 430fe9fe9a3616e17ac90a6839d5172a884b604a Mon Sep 17 00:00:00 2001 From: Linus Dierheimer Date: Mon, 11 Apr 2022 18:54:56 +0200 Subject: [PATCH] Avoid unnecessary cache validation --- src/common/caching.c | 3 +++ src/common/init.c | 4 +++- src/fastfetch.c | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/common/caching.c b/src/common/caching.c index e5e95ba8d..5e09c4be5 100644 --- a/src/common/caching.c +++ b/src/common/caching.c @@ -35,6 +35,9 @@ static void writeCacheFile(FFinstance* instance, const char* moduleName, const c void ffCacheValidate(FFinstance* instance) { + if(instance->config.recache) + return; + FFstrbuf content; ffStrbufInit(&content); readCacheFile(instance, "cacheversion", "ffv", &content); diff --git a/src/common/init.c b/src/common/init.c index 60e4d9887..9d4e4b567 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -222,7 +222,6 @@ void ffInitInstance(FFinstance* instance) { initState(&instance->state); defaultConfig(instance); - ffCacheValidate(instance); } static void resetConsole(bool disableLinewrap, bool hideCursor) @@ -256,6 +255,9 @@ void ffStart(FFinstance* instance) sigaction(SIGTERM, &action, NULL); sigaction(SIGQUIT, &action, NULL); + //We do the cache validation here, so we can skip it if --recache is given + ffCacheValidate(instance); + //reset everything to default before we start printing fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout); diff --git a/src/fastfetch.c b/src/fastfetch.c index 5f7e51904..1f5e45f14 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -693,7 +693,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con else if(strcasecmp(key, "-r") == 0 || strcasecmp(key, "--recache") == 0) { - //Set cacheSave as well, beacuse the user expects the values to be cached when expliciting using --recache + //Set cacheSave as well, because the user expects the values to be cached when expliciting using --recache instance->config.recache = optionParseBoolean(value); instance->config.cacheSave = instance->config.recache; }