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
+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);