From f0b9800974c09ade7e4f02d81bfbcfe0110c820c Mon Sep 17 00:00:00 2001 From: Linus Dierheimer Date: Wed, 23 Mar 2022 11:38:42 +0100 Subject: [PATCH] Fix fastfetch recaching every time if an old cache exists --- CMakeLists.txt | 4 ++-- src/common/io.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 52eb150cf..7d9a43c8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,13 +1,13 @@ cmake_minimum_required(VERSION 3.1.0) # Threads::Threads project(fastfetch - VERSION 1.1.0 + VERSION 1.1.1 LANGUAGES C ) #e.g. +1 #This allows to track builds between versions, without GitHub creating a new release -set(PROJECT_VERSION_EXTRA "+1") +set(PROJECT_VERSION_EXTRA "") include(GNUInstallDirs) diff --git a/src/common/io.c b/src/common/io.c index b1e230e55..5b9516341 100644 --- a/src/common/io.c +++ b/src/common/io.c @@ -246,9 +246,10 @@ void ffCacheValidate(FFinstance* instance) ffStrbufInit(&content); ffAppendFileContent(path.chars, &content); - if(ffStrbufCompS(&content, FASTFETCH_PROJECT_VERSION) == 0) + bool isSameVersion = ffStrbufCompS(&content, FASTFETCH_PROJECT_VERSION) == 0; + ffStrbufDestroy(&content); + if(isSameVersion) { - ffStrbufDestroy(&content); ffStrbufDestroy(&path); return; } @@ -261,7 +262,6 @@ void ffCacheValidate(FFinstance* instance) ffWriteFileContent(path.chars, &version); ffStrbufDestroy(&version); - ffStrbufDestroy(&content); ffStrbufDestroy(&path); } @@ -409,7 +409,7 @@ bool ffWriteFDContent(int fd, const FFstrbuf* content) void ffWriteFileContent(const char* fileName, const FFstrbuf* content) { - int fd = open(fileName, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + int fd = open(fileName, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if(fd == -1) return;