fixed a bug in caching

This commit is contained in:
Linus Dierheimer
2021-02-22 20:53:12 +01:00
parent fea8e371e4
commit 0ec63d64fa
10 changed files with 19 additions and 35 deletions
+1 -2
View File
@@ -19,8 +19,7 @@ set(PROJECT_VERSION "r${GIT_REV_LIST}.${GIT_REV_PARSE}")
include (${CMAKE_ROOT}/Modules/FindX11.cmake)
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -march=native -O3 -pipe -fno-plt") # for testing
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -march=native -O3 -pipe -fno-plt")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -march=native -O3 -pipe -fno-plt") # for testing
configure_file(src/fastfetch_config.h.in fastfetch_config.h)
include_directories(${PROJECT_BINARY_DIR})
+2 -4
View File
@@ -35,8 +35,6 @@ void ffPrintCPU(FFstate* state)
char value[1024];
sprintf(value, "%s (%i) @ %.9gGHz", name, get_nprocs(), ghz);
ffSaveCachedValue(state, "CPU", value);
ffPrintLogoAndKey(state, "CPU");
puts(value);
ffPrintAndSaveCachedValue(state, "CPU", value);
}
+9 -4
View File
@@ -138,21 +138,26 @@ bool ffPrintCachedValue(FFstate* state, const char* key)
return false;
char value[1024];
if(read(fd, value, sizeof(value) - 1) < 1)
ssize_t readed = read(fd, value, sizeof(value) - 1);
if(readed < 1)
return false;
value[1023] = '\n'; //Ensure that we end with a newline, even when we didn't fully read the file
close(fd);
value[readed] = '\0'; //Somehow read doesn't alway do this
ffPrintLogoAndKey(state, key);
puts(value);
return true;
}
void ffSaveCachedValue(FFstate* state, const char* key, const char* value)
void ffPrintAndSaveCachedValue(FFstate* state, const char* key, const char* value)
{
ffPrintLogoAndKey(state, key);
puts(value);
char fileName[256];
getCacheFileName(state, key, fileName);
+1 -1
View File
@@ -56,7 +56,7 @@ void ffParsePropFileHome(FFstate* state, const char* relativeFile, const char* r
void ffPrintGtkPretty(const char* gtk2, const char* gtk3, const char* gtk4);
void ffPrintError(FFstate* state, const char* key, const char* message);
bool ffPrintCachedValue(FFstate* state, const char* key);
void ffSaveCachedValue(FFstate* state, const char* key, const char* value);
void ffPrintAndSaveCachedValue(FFstate* state, const char* key, const char* value);
void ffLoadLogoSet(FFstate* state, const char* logo);
void ffLoadLogo(FFstate* state);
+1 -4
View File
@@ -31,10 +31,7 @@ static void handleGPU(FFstate* state, struct pci_access* pacc, struct pci_dev* d
strcat(gpu, name);
ffSaveCachedValue(state, key, gpu);
ffPrintLogoAndKey(state, key);
puts(gpu);
ffPrintAndSaveCachedValue(state, key, gpu);
}
void ffPrintGPU(FFstate* state)
+1 -4
View File
@@ -31,8 +31,5 @@ void ffPrintHost(FFstate* state)
fclose(versionFile);
}
ffSaveCachedValue(state, "Host", host);
ffPrintLogoAndKey(state, "Host");
puts(host);
ffPrintAndSaveCachedValue(state, "Host", host);
}
+1 -4
View File
@@ -13,8 +13,5 @@ void ffPrintLocale(FFstate* state)
return;
}
ffSaveCachedValue(state, "Locale", locale);
ffPrintLogoAndKey(state, "Locale");
puts(locale);
ffPrintAndSaveCachedValue(state, "Locale", locale);
}
+1 -4
View File
@@ -16,8 +16,5 @@ void ffPrintOS(FFstate* state)
char os[1024];
sprintf(os, "%s %s", name, state->utsname.machine);
ffSaveCachedValue(state, "OS", os);
ffPrintLogoAndKey(state, "OS");
puts(os);
ffPrintAndSaveCachedValue(state, "OS", os);
}
+1 -4
View File
@@ -13,8 +13,5 @@ void ffPrintResolution(FFstate* state)
char resolution[1024];
sprintf(resolution, "%ix%i", screen->width, screen->height);
ffSaveCachedValue(state, "Resolution", resolution);
ffPrintLogoAndKey(state, "Resolution");
puts(resolution);
ffPrintAndSaveCachedValue(state, "Resolution", resolution);
}
+1 -4
View File
@@ -21,8 +21,5 @@ void ffPrintShell(FFstate* state)
else if(shellName[0] == '/')
++shellName;
ffSaveCachedValue(state, "Shell", shellName);
ffPrintLogoAndKey(state, "Shell");
puts(shellName);
ffPrintAndSaveCachedValue(state, "Shell", shellName);
}