From 531ddb4880dea6fa6a9973fae70aea373f5aa6bc Mon Sep 17 00:00:00 2001 From: Lorenz Stechauner Date: Tue, 16 Mar 2021 21:54:49 +0100 Subject: [PATCH] Caching debug messages --- src/cache.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cache.c b/src/cache.c index f04b70d..16065f7 100644 --- a/src/cache.c +++ b/src/cache.c @@ -73,6 +73,7 @@ int cache_process() { for (int i = 0; i < FILE_CACHE_SIZE; i++) { if (cache[i].filename[0] != 0 && cache[i].meta.etag[0] == 0 && !cache[i].is_updating) { cache[i].is_updating = 1; + fprintf(stdout, "Hashing file '%s'...\n", cache[i].filename); SHA1_Init(&ctx); file = fopen(cache[i].filename, "rb"); compress = strncmp(cache[i].meta.type, "text/", 5) == 0 || @@ -97,10 +98,11 @@ int cache_process() { } buf[strlen(rel_path)] = 0; sprintf(filename_comp, "%.*s/.necronda-server/cache/%s.z", cache[i].webroot_len, cache[i].filename, buf); + fprintf(stdout, "Compressing file '%s'...\n", cache[i].filename); comp_file = fopen(filename_comp, "wb"); if (comp_file == NULL) { compress = 0; - fprintf(stderr, ERR_STR "Unable to open cache file: %s" CLR_STR "\n", strerror(errno)); + fprintf(stderr, ERR_STR "Unable to open cached file: %s" CLR_STR "\n", strerror(errno)); } else { strm.zalloc = Z_NULL; strm.zfree = Z_NULL; @@ -131,6 +133,7 @@ int cache_process() { if (compress) { deflateEnd(&strm); fclose(comp_file); + fprintf(stdout, "Finished compressing file '%s'\n", cache[i].filename); strcpy(cache[i].meta.filename_comp, filename_comp); } else { memset(cache[i].meta.filename_comp, 0, sizeof(cache[i].meta.filename_comp)); @@ -141,12 +144,14 @@ int cache_process() { sprintf(cache[i].meta.etag + j * 2, "%02x", hash[j]); } fclose(file); + fprintf(stdout, "Finished hashing file '%s'\n", cache[i].filename); cache[i].is_updating = 0; cache_changed = 1; } } if (cache_changed) { + cache_changed = 0; cache_file = fopen("/var/necronda-server/cache", "wb"); fwrite(cache, sizeof(cache_entry), FILE_CACHE_SIZE, cache_file); fclose(cache_file);