Skip to content

Commit 430fe9f

Browse files
Avoid unnecessary cache validation
1 parent 8831c07 commit 430fe9f

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/common/caching.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ static void writeCacheFile(FFinstance* instance, const char* moduleName, const c
3535

3636
void ffCacheValidate(FFinstance* instance)
3737
{
38+
if(instance->config.recache)
39+
return;
40+
3841
FFstrbuf content;
3942
ffStrbufInit(&content);
4043
readCacheFile(instance, "cacheversion", "ffv", &content);

src/common/init.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ void ffInitInstance(FFinstance* instance)
222222
{
223223
initState(&instance->state);
224224
defaultConfig(instance);
225-
ffCacheValidate(instance);
226225
}
227226

228227
static void resetConsole(bool disableLinewrap, bool hideCursor)
@@ -256,6 +255,9 @@ void ffStart(FFinstance* instance)
256255
sigaction(SIGTERM, &action, NULL);
257256
sigaction(SIGQUIT, &action, NULL);
258257

258+
//We do the cache validation here, so we can skip it if --recache is given
259+
ffCacheValidate(instance);
260+
259261
//reset everything to default before we start printing
260262
fputs(FASTFETCH_TEXT_MODIFIER_RESET, stdout);
261263

src/fastfetch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
693693

694694
else if(strcasecmp(key, "-r") == 0 || strcasecmp(key, "--recache") == 0)
695695
{
696-
//Set cacheSave as well, beacuse the user expects the values to be cached when expliciting using --recache
696+
//Set cacheSave as well, because the user expects the values to be cached when expliciting using --recache
697697
instance->config.recache = optionParseBoolean(value);
698698
instance->config.cacheSave = instance->config.recache;
699699
}

0 commit comments

Comments
 (0)