From: Anders F Björklund Date: Mon, 9 Apr 2018 18:35:25 +0000 (+0200) Subject: Print the time when stats last updated X-Git-Tag: v3.5~68 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ea35e06fd54736fd9307ff2d419c54e0f4a525f;p=thirdparty%2Fccache.git Print the time when stats last updated --- diff --git a/src/stats.c b/src/stats.c index 5ac56fdc2..6c81d2dcc 100644 --- a/src/stats.c +++ b/src/stats.c @@ -445,6 +445,8 @@ stats_summary(struct conf *conf) { struct counters *counters = counters_init(STATS_END); time_t oldest = 0; + time_t updated = 0; + struct stat st; assert(conf); @@ -464,6 +466,11 @@ stats_summary(struct conf *conf) if (current != 0 && (oldest == 0 || current < oldest)) { oldest = current; } + if (stat(fname, &st) == 0) { + if (st.st_mtime > updated) { + updated = st.st_mtime; + } + } free(fname); } @@ -478,6 +485,12 @@ stats_summary(struct conf *conf) strftime(timestamp, sizeof(timestamp), "%c", tm); printf("stats zero time %s\n", timestamp); } + if (updated) { + struct tm *tm = localtime(&updated); + char timestamp[100]; + strftime(timestamp, sizeof(timestamp), "%c", tm); + printf("stats updated %s\n", timestamp); + } // ...and display them. for (int i = 0; stats_info[i].message; i++) {